1. Put the collection in another example.
Add another class classlibrary1 to define all collections
2. Reference this type of metadata in webmvc example.
For normal use, the following definitions must be made in the global. asax file in this example.
Public Static Void Registerroutes (routecollection routes)
{
Routes. ignoreroute ( " {Resource}. axd/{* pathinfo} " );
Routes. maproute (
" Default " , // Route name
" {Controller}/{action}/{ID} " , // URL with Parameters
New {Controller = " Home " , Action = " Index " , Id = urlparameter. optional} // Parameter defaults
, New String [] { " Classlibrary1 " }
);
}
The namespace of the collection to be added here.
3. In order to use a different file to upload a facial file, follow these steps:
3.1 create a file named viewtest, and then define the same object as the default view file. If you do not want to create a shard file, you can use.
3.2 Add a web. config file. The same as the default view. Otherwise, the response is abnormal.
3.3 Add the _ viewstart. cshtml file. The same as the default view.
3.4 is mixed in my memory.
3.5 then, in the global. asax file, make the following definitions:
Public Static Void Registerroutes (routecollection routes)
{
Razorviewengine razor = New Razorviewengine ();
Razor. viewlocationformats = New String [] {
" ~ /Viewtest/{1}/{0}. cshtml " ,
" ~ /Viewtest/{1}/{0}. vbhtml " ,
" ~ /Views/shared/{0}. cshtml " ,
" ~ /Views/shared/{0}. vbhtml " };
Viewengines. Engines. Clear ();
Viewengines. Engines. Add (razor );
Routes. ignoreroute ( " {Resource}. axd/{* pathinfo} " );
Routes. maproute (
" Default " , // Route name
" {Controller}/{action}/{ID} " , // URL with Parameters
New {Controller = " Home " , Action = " Index " , Id = urlparameter. optional} // Parameter defaults
, New String [] { " Classlibrary1 " }
);
}
In response to the above token statement:
Define a razorviewengine, and then redefine viewlocationformats. Tell the view where to search.
It's very simple.