开发者

asp mvc 2 areas [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, inc开发者_开发技巧omplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 10 years ago.

can i disable compiling of routing and other asax files? to change them, when application running already


No. Anything with a .cs extension (like global.asax.cs) has to be compiled. What are you really trying to do? The compiler is pretty quick. If you're just trying to debug your routes, you can use something like the route debugger (wonderful, wonderful tool).

Update based on comment

Your comment says that you want to store routes outside of the compiled code.

This link describes how to store them in a database, which I feel is the best place. The example is from 2008 so it's probably not compatible with the MVC3, but it should give you an idea of where to start.

If you don't want to go through the trouble of building an editor (or worse, manually entering them in your database), an XML file is acceptable. This link describes loading routes from an XML file.

The techniques are all pretty much the same:

  • Create a class which can load route data from a store. The simplest may be:
    1. Route Name
    2. route string (ie, "{controller}/{action}/{id}"

but you'll probably want to include defaults for controller name, action name, etc.

  • In Application_Start, use that class to load and register the routes:

...

List<Route> routes = MyRouteLoader.Load(routeXmlFileName);
foreach(Route route in routes)
{
    routes.add(route);
}

The only semi-complex part is loading the routes from the XML, but you may be able to use the System.Xml.Serialization.XmlSerializer class to read and write the routes to your XML with little custom code.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜