What do we have to do in order to push configurations like URL route mappings to ASP.NET MVC Views to an XML file?

StackOverflow https://stackoverflow.com/questions/15958307

문제

All:

We started off our project using ASP.NET Web Forms.

We decided to integrate ASP.NET MVC 4 into our project.

We would like to leave the existing .aspx ASP.NET Web Form pages as it is already.

It would be too much work effort for now to move the existing functionality in .aspx ASP.NET Web Forms to ASP.NET MVC 4.

However, we want new functionality to use ASP.NET MVC 4 technology.

So I created a Global.asax.cs file.

I've taken into consideration existing .aspx ASP.NET Web Form pages by including the following line of code which is a catch-all route for .aspx ASP.NET Web Form pages:

routes.IgnoreRoute("{resource}.aspx/{*pathInfo}");

The Global.asax.cs also contains URL route mappings to ASP.NET MVC Views.

routes.MapRoute(
             "Default",
             // Route name
             "{controller}/{action}/{id}",
            // URL with parameters
            new { controller = "Home", action = "Index", id = "" }
            // Parameter defaults
            );

Here's what I don't like about ASP.NET MVC.
I don't like configuring the URL route mappings to ASP.NET MVC Views in a compiled C# file. I believe that configurations like URL route mappings to ASP.NET MVC Views should be in some kind of xml file.

What do we have to do in order to push configurations like URL route mappings to ASP.NET MVC Views to an XML file?

도움이 되었습니까?

해결책

Do you really need to change urls on production without changind something in code? It is really an odd situation. But anyway there are no any out of box way of doing this. However, nothing prevents you from creating your own section in web.config, then reading it in the Application_Start and calling routes.MapRoute() for every row in the section. But i am pretty sure i don't need it.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top