ASP.NET MVC Óû§ÑéÖ¤ºÍȨÏÞÑéÖ¤
The MVC bits have finally arrived and I’ve spent a while digesting them. I’ve been waiting for the bits to be released to begin working on a side-project, so the first thing I did after downloading them last night was crank it up and start working on a new ASP.NET MVC Web Application project.
Typically, the first thing I do on a new project is set up the authentication/authorization system. For the project I am working on I want to use the ASP.Net Membership system, but most of the Membership controls do not work with the MVC framework because they require postbacks. I spent some time last night building a Security controller and views for Registration and Login that I thought would be worth sharing.
So far I have implemented basic functionality for Register, Login, and Logout. There are three files we will have to create. We will also have to change the routing table. Let’s start with the SecurityController:
1 public class SecurityController : Controller
2 {
3
4 [ControllerAction]
5 public void Login()
6 {
7 RenderView("Login");
8 }
9
10 [ControllerAction]
11 public void Register()
12 {
13 RenderView( "Register" );
14 }
15
16 [ControllerAction]
17 public void Logout()
18 {
19 FormsAuthe
Ïà¹ØÎĵµ£º
×î½üÕýÔÚѧϰ ASP.NET£¨C#£© ,¸Ð¾õÈÏʶÉÏÈ¥Á˾Ͳ»ÊÇÄÇôÄÑÒÔÀí½âÁË¡£ÎÒÊÇASP ³öÉí£¬ÓеÄʱºòѧASP.NET ×ÜÊÇ»ìÏýµÄһЩµØ·½¡£ºÇºÇ£¬²»¹ýÀí½âÉÏÈ¥Á˾ͺúܶàÁË¡£ÎÒÏ£ÍûºÃÅóÓÑÃÇÌáÌáºÃµÄ½¨Òé¡£°ï°ïСµÜ£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡1 ......
//postÇëÇó
string name = Request["name"].toString();
string name =Request.Form.Get("name").toString();
//getÇëÇó
string name = Request.QueryString["name"].toString();
µ«ÎÒ·¢ÏÖ ÎÞÂÛÊÇ·ñÊÇpostÓëget´«Öµ¶¼¿ÉÓÃ
string name = Request["name"].toString();
±íµ¥Ìá½»ÖÐgetºÍpost·½Ê½µÄÇø±ð¹éÄ ......
1.Ö»ÒªÇó±£ÁôNλ²»ËÄÉá5Èë
¡¡¡¡float f = 0.55555f£»int i =£¨int£©£¨f * 100£©£»f = £¨float£©£¨i*1.0£©/100£»
¡¡¡¡2.±£ÁôN룬ËÄÉáÎåÈë .
¡¡¡¡decimal d= decimal.Round£¨decimal.Parse£¨"0.55555"£©£¬2£©£»
¡¡¡¡3.±£ÁôNλËÄÉáÎåÈë
¡¡¡¡Math.Round£¨0.55555£¬2£©
¡¡¡¡4£¬±£ÁôNλËÄÉáÎåÈë
¡¡¡¡double dbdata = 0.5 ......
Cookie ÊÇʲô£¿
ÔÚasp.netÖУ¬ÈçºÎʹÓã¿
1 Cookie ÊÇʲô£¿
Cookie£ºµçÄÔÖмǼÓû§ÔÚÍøÂçÖеÄÐÐΪµÄÎļþ£»ÍøÕ¾¿Éͨ¹ýCookieÀ´Ê¶±ðÓû§ÊÇ·ñÔø¾·ÃÎʹý¸ÃÍøÕ¾¡££¨Õª×Ô http://gb.cri.cn/17004/2007/03/08/121@1487554.htm£©
2ÔÚasp.netÖУ¬ÈçºÎʹÓã¿
& ......
ÔÚ×öWEBϵͳ¿ª·¢Ê±£¬Ã¿Ã¿Óöµ½Ò³Ãæ´«ÖµµÄÎÊÌⶼÊÇÔÚʹÓÃ×î¼òµ¥µÄGET·½Ê½À´´«Öµ£¬Èç¹ûÐÅÏ¢Á¿±È½ÏÉÙ²¢ÇÒÓÖ²»Éæ¼°°²È«ÎÊÌâµÄ»°
»¹¿ÉÒÔÓ¦¸¶Ò»Ï£¬µ«ÊÇ´«µÝ´óÁ¿Êý¾Ý¡¢Ãô¸ÐÊý¾ÝµÄʱºò.....
ÏÂÃæ¾ÍASP.NETÖÐÒ³Ãæ´«Öµ·½Ê½×ö¸ö»ã×Ü£¬ÒÔ±¸²»Ê±Ö»Ðè
1¡¢GET´«Öµ·½Ê½
·¢ËÍÒ³Ã棺
  ......