开发者

Can I add an ASPX page to an MVC project WITHOUT involving any Controllers?

I have an interesting situation where I need to quickly provide a feature to a customer prior to our normal build schedule and outside of our normal build repository. I need it to go live tonight, without a recompile.

Our site is deployed with everything compiled into a DLL, besides the Views. This means that at anytime I can edit the Views on the fly in the middle of the day. Is there a way I can add a new page that can be invoked via HTTP GET or POST so that I can do some things I would normally do in a C开发者_如何学Goontroller without actually making a new Action, etc? I know this is not a good methodology and it won't be the long term solution, I just need a plan... business is business after all.

Edit: I also cannot edit the Global.asax routing table, it is also compiled.


The first thing you'd have to do is pull out your Routes into XML files so you could add routes on the fly (all it'd do is recycle the App-Pool). I also recommend pulling the Routes out of the web.config into their own .config file, that's referenced in the web.config.

The second thing is you would have to mix Webforms with ASP.NET MVC if you wanted to do this.

It's important to note that using UrlParameter.Optional is problematic with XML based routing, at least I never got it to work.


I believe because of the way routing works in MVC it will try to find a valid path using the Routing system first. Failing that it should look for the aspx page using the normal method of just looking for the file. Keep in mind that aspx files (or razor files) that are just asp.net pages should not be in the Views folder, as MVC apps are configured to refuse serving up files in that directory. I'm assuming your're just talking about a single page or two? Anything more complex than that and I would look at trying to separate them more strongly as in the article mentioned above.


You could mix classic webforms with MVC.


I'm almost positive you could add a new Controller class to the App_Code folder and it would get picked up without a compile needed.

I guess it all depends if you have a convention based route that will hit it or not.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜