This skin change refers to the dynamic switching of view folders, not CSS and image, you know ....
It is also very easy to use. The core is just a few words:
Public class Global: system. Web. httpapplication
{
Protected void application_start (Object sender, eventargs E)
{
Initrouting (routetable. routes );
// Use the Custom Skin view engine skinviewengine
// The View folder is/skins/skin name/controller name/
// Set the skin: httpcontext. setskinname (skin );
// Obtain the skin: String skinname = httpcontext. getskinname ();
Viewengines. Engines. Clear ();
Viewengines. Engines. Add (New skinviewengine (getskins ()));
}
Private Static void initrouting (routecollection routes)
{
Routes. maproute ("default", "{controller}/{action}", new {controller = "engine", Action = "Index "});
}
// (Traverse the skins directory) obtain all skin solutions provided by the website
Public static string [] getskins ()
{
List <string> skins = new list <string> ();
String skinfolder = httpcontext. Current. server. mappath ("~ /Skins /");
Foreach (string folder in directory. getdirectories (skinfolder ))
Skins. Add (New directoryinfo (folder). Name );
Return skins. toarray ();
}
}
Download the code:/files/surfsky/mvcskindemo.rar