As long as the server supports. Net 4, the ASP. net mvc 3 Application can be generated and deployed on it.Program.
Method 1 (normal method): Install ASP. net mvc 3 to the machine, program assembly to GAC, all web projects on the machine can reference/use these sets in GAC
Method 2: copy the ASP. net mvc 3 assembly to the/bin folder of the web project, and then let the web project reference/use the assembly.
Method 2 practices in another blog (http://drew-prog.blogspot.com/2011/01/how-to-deploy-aspnet-mvc-3-app-to-web.html,), steps are as follows:
Step 2: add an explicit reference to MVC and the Assembly on which it depends. Add the following Assembly to:
- Microsoft. Web. Infrastructure
- System. Web. helpers
- System. Web. MVC
- System. Web. Razor
- System. Web. webpages
- System. Web. webpages. Deployment
- System. Web. webpages. Razor
Step 1: Modify the copy to local property to true. This will make these assemblies be copied to the/bin folder.
Step 1: rebuild and deploy the project in a normal process.
With the release of mvc3.0rtm, the company recently upgraded its project from mvc2.0 to mvc3.0. In addition, we plan to use the razor template engine in mvc3. Now I will share with you what razor has learned. If there are any shortcomings, please point out.
Actually calling C # in HTML #CodeAlways complaining. This statement is very troublesome. Where is the trouble? It is actually closed. For example:
Asp.net:<SCRIPT src = "<% = URL. Content ("~ /Scripts/jquery-1.4.4.min.js ") %>"
Razor:<SCRIPT src = "@ URL. Content ("~ /Scripts/jquery-1.4.4.min.js ")"
Obviously, Razor helped us close it internally."%>". In fact, this small closure allows us to call the server code more smoothly in HTML. Therefore, Razor makes development easier! The following describes the basic usage of razor.
I. template page
After Razor appears, we can choose not to use the Asp.net master template page. Instead, it is the template file of cshtml razor. I personally think it is similar to the master template page. However, the original functions of the mater template page are further extended to facilitate development. For example, if you add the _ viewstart. cshtml file to the view folder, you do not need to introduce the template page to each specific view page. Reduce duplicate code on the view page. Specifically, you can create an mvc3 application and select the razor template. Vs will automatically establish the above mechanism. The @ rendersection method is worth mentioning here. We can preset an area on the template page and use it for the view that inherits the template page in the future. For details, see the following operations:
Add the following code to the _ layout. cshtml template file in the mvc3.0 shared folder:
?
12345678910 |
<! Doctype HTML> < Html > < Head > <
Title > @ Viewbag. Title </ Title > < Link Href = "@ URL. Content (" ~ /Content/site.css ")" REL = "Stylesheet" Type = "Text/CSS" />
< Script SRC = "@ URL. Content (" ~ /Scripts/jquery-1.4.4.min.js ")" Type = "Text/JavaScript" > </ Script > @ Rendersection ("head", required: True) </ Head
> < Body > < Div Class = "Page" > |
The above Code contains Row 3 and a head section is reserved. If you are familiar with the template page, you should understand that it is reserved for custom JS/CSS for specific view pages in the future. For this view, we will use the index under the default home for example. Open index. cshtml and write the following code
?
1234567891011 |
@{
Viewbag. Title = "home page "; } < H2 > @ Viewbag. Message </ H2 > @ Section head { < Script Type = "Text/JavaScript" >
$ (Function (){ Alert ("Hello jquery "); }); </ Script > } |
This view has already been integrated with the template page. Here we only fill in the head section in the template page. Then we can add our JS or CSS for each view page. At this point, we have achieved an exclusive personality.
Ii. Razor Syntax:
ArticleAs mentioned at the beginning, I personally think that the convenience of razor syntax is that razor automatically helps us to close the syntax of C # Or VB. NET in HTML. See the following code:
The comments have been provided, so it is not difficult to read them carefully. You can also understand that it is "painful" to replace razor with Asp.net's <% = %> or <%: %>. For other razor usage, the official website has been fully written. For exampleHTML encod prevents XSS attacks. Razor is a keyword that can be automatically recognized as an email rather than a razor.
3. Razor intelligent syntax prompt:
The smart prompt is the same as that in vs. You only need to call up ctrol + J. For details, see:
Are you planning to fully use razor in Web development like me?
As long as the server supports. Net 4, ASP. net mvc 3 applications can be generated and deployed on the server.
Method 1 (normal method): Install ASP. net mvc 3 to the machine, program assembly to GAC, all web projects on the machine can reference/use these sets in GAC
Method 2: copy the ASP. net mvc 3 assembly to the/bin folder of the web project, and then let the web project reference/use the assembly.
Method 2 practices in another blog (http://drew-prog.blogspot.com/2011/01/how-to-deploy-aspnet-mvc-3-app-to-web.html,), steps are as follows:
Step 2: add an explicit reference to MVC and the Assembly on which it depends. Add the following Assembly to:
- Microsoft. Web. Infrastructure
- System. Web. helpers
- System. Web. MVC
- System. Web. Razor
- System. Web. webpages
- System. Web. webpages. Deployment
- System. Web. webpages. Razor
Step 1: Modify the copy to local property to true. This will make these assemblies be copied to the/bin folder.
Step 1: rebuild and deploy the project in a normal process.
With the release of mvc3.0rtm, the company recently upgraded its project from mvc2.0 to mvc3.0. In addition, we plan to use the razor template engine in mvc3. Now I will share with you what razor has learned. If there are any shortcomings, please point out.
In fact, when calling C # code in HTML, I am always complaining. This statement is very troublesome. Where is the trouble? It is actually closed. For example:
Asp.net:<SCRIPT src = "<% = URL. Content ("~ /Scripts/jquery-1.4.4.min.js ") %>"
Razor:<SCRIPT src = "@ URL. Content ("~ /Scripts/jquery-1.4.4.min.js ")"
Obviously, Razor helped us close it internally."%>". In fact, this small closure allows us to call the server code more smoothly in HTML. Therefore, Razor makes development easier! The following describes the basic usage of razor.
I. template page
After Razor appears, we can choose not to use the Asp.net master template page. Instead, it is the template file of cshtml razor. I personally think it is similar to the master template page. However, the original functions of the mater template page are further extended to facilitate development. For example, if you add the _ viewstart. cshtml file to the view folder, you do not need to introduce the template page to each specific view page. Reduce duplicate code on the view page. Specifically, you can create an mvc3 application and select the razor template. Vs will automatically establish the above mechanism. The @ rendersection method is worth mentioning here. We can preset an area on the template page and use it for the view that inherits the template page in the future. For details, see the following operations:
Add the following code to the _ layout. cshtml template file in the mvc3.0 shared folder:
?
12345678910 |
<! Doctype HTML> < Html > < Head > < Title > @ Viewbag. Title </ Title > < Link Href
= "@ URL. Content (" ~ /Content/site.css ")" REL = "Stylesheet" Type = "Text/CSS" /> < Script SRC = "@ URL. Content (" ~ /Scripts/jquery-1.4.4.min.js ")"
Type = "Text/JavaScript" > </ Script > @ Rendersection ("head", required: True) </ Head > < Body > < Div Class = "Page" > |
The above Code contains Row 3 and a head section is reserved. If you are familiar with the template page, you should understand that it is reserved for custom JS/CSS for specific view pages in the future. For this view, we will use the index under the default home for example. Open index. cshtml and write the following code
?
1234567891011 |
@{ Viewbag. Title = "home page "; } < H2 > @ Viewbag. Message </ H2 >
@ Section head { < Script Type = "Text/JavaScript" > $ (Function (){ Alert ("Hello jquery "); });
</ Script > } |
This view has already been integrated with the template page. Here we only fill in the head section in the template page. Then we can add our JS or CSS for each view page. At this point, we have achieved an exclusive personality.
Ii. Razor Syntax:
As mentioned at the beginning of this article, I personally think that the convenience of razor syntax is that razor automatically helps us to close the syntax of C # Or VB. NET in HTML. See the following code:
The comments have been provided, so it is not difficult to read them carefully. You can also understand that it is "painful" to replace razor with Asp.net's <% = %> or <%: %>. For other razor usage, the official website has been fully written. For exampleHTML encod prevents XSS attacks. Razor is a keyword that can be automatically recognized as an email rather than a razor.
3. Razor intelligent syntax prompt:
The smart prompt is the same as that in vs. You only need to call up ctrol + J. For details, see:
Are you planning to fully use razor in Web development like me?