Mixing ASP.NET Webforms with Friendly URLs with new ASP.NET MVC stuff - webforms

I have a number of "old-style" ASP.NET 4.x Webforms applications. For future development, we're thinking about switching to ASP.NET MVC 5, and we plan to basically add new features as MVC code to our existing apps.
Now I found a number of interesting articles on how to mix Webforms and ASP.NET MVC, and one of the topics usually is around routing. Typically, the consensus is to define a "route ignore" setting for all *.aspx requests - those get handled by the "old" Webforms runtime.
This is all nice and fine - but we're already using the Webforms "friendly URL" feature - so our requests are like
http://myserver.com/myapp/customer/42
http://myserver.com/myapp/product/edit/57
and we don't have any ".aspx" in our query string anymore.
So given this setup - Webforms 4.5.x with Friendly URL's (without the ".aspx" indicator) - how do I make sure that my new MVC routes don't collide with existing Webforms friendly URLs ?
Do I need to stick all the MVC stuff into an "area" (or several) and just define those URLs as the MVC routes? E.g.
http://myserver.com/myapp/mvc/newhotness/404
***
or are there other, more compelling approaches to this?

Related

Is it a good practice to use one URL for entire application in ASP.NET MVC Project?

I have an ASP.NET MVC project that use ajax for load part of page in entire application use #Html.Partial.My client request's is the website should have only one URL.I'm at the beginning of the project and it is a big clinic management system. I want my codes be reusable for other projects and have a nice performance. Can i do that with this approach?

GetOverriddenBrowser() for ASP.NET MVC 3

ASP.NET MVC 4 has some nice mobile features which are replacing my mutant mobile view engines, but until it's production ready, I'd like to implement the browser override feature for ASP.NET MVC 3.
SetOverriddenBrowser() seems to set a .ASPXBrowserOverride cookie with an overriding User Agent that returns an HttpBrowserCapabilitiesBase object via HttpContext.GetOverriddenBRowser().
What would be the simplest way of implementing this feature for MVC 3 to make use of the mobile detection library, including 51Degrees.mobi?
There is a blog post on the 51Degrees.mobi site that you might find useful. Check it out here. It covers the implementation of 51Degrees with MVC 4.

A good substitute for ASMX web service methods, but not a general handler

The best thing I like about ASP.NET MVC, is that you can directly call a server method (called action), from the client. This is so convenient, and so straightforward, that I really like to implement such a model in ASP.NET WebForms too.
However, in ASP.NET WebForms, to call a server method from the client, you should either use Page Methods, or Web Services, both of which use SOAP as their communication protocol (though JSON can also be used).
There is also another substitution, which is using Generic Handlers. The problem with them however is that, a separate Generic Handler should be written for each server method. In other words, each Generic Handler works like a simple method.
Is there anyway else to imitate MVC model in ASP.NET WebForms?
Please note that I can't change to MVC platform right now, cause the project at our hand is a big project and we don't have required resources and time to change our platform. What we seek, is a simple MVC model implementation for our AJAX calls. A problem that we have with Web Services, is the known problem of SoapException, and we're not interested in creating custom SoapExctensions.
You can mix ASP.NET MVC and ASP.NET Webforms in the same project. You'll just need to add the correct MVC parts to your current Webforms project and have the best of both worlds.
http://www.aspnetmvcninja.com/general/mixing-asp-net-mvc-and-webforms has a good walkthrough of all the steps you'll need to take to get it working.
You can splice your asp.net webforms app with something like Nancy perhaps?
I've had great success with Nancy and Knockout after I abandoned the horrible Ajax Control Toolkit.
(Apologies if I have misunderstood your question - I read it twice)

Integrating/switching to MVC3 from WebForms with large existing library of custom controls

Here's the situation. We're adding a new application to our suite of webapps based on WebForms and so I felt this would be the perfect time to introduce MVC.
I did all the research about intermingling the two and got the project all set up using an Area that uses MVC routes while the rest of the (visual studio) project runs with web forms the way it's been running.
Master pages were converted to Razor layouts, not too bad because there was only one master page that was shared between every application.
The problem I've run into now is reusing user controls. We have dozens of custom user controls, many of them fairly complex, that are reused throughout all of our applications. Most of them (especially ones that would be difficult to port) do a fair amount with ViewState and postbacks.
If it were just a matter of rewriting these in MVC, the one time cost would be less than ideal but not terrible. But since the existing apps need to be maintained and updated as well, it seems like maintaining 2 versions of the same behaviour using entirely different paradigms would be a huge drain on productivity.
My gut says there isn't really a good solution and we may have to abandon the idea of going to MVC for this project and stick with webforms, but I wanted to see if the SO community has any insight on what to do in this scenario.
If you have the budget to rewrite those server side controls using the MVC paradigm that would be the best way to go. If not, you could still embed them into existing classic WebForms pages and which would communicate with the new MVC application using standard HTTP/HTML techniques: form posts, sending ids through query string parameters, iframes, cookies, HTML 5 storages, etc... One thing's for sure though: try to avoid putting those server side controls in your MVC views. You will end up with some hybrid application that is neither proper ASP.NET MVC nor a proper WebForms which would be a disaster.
Personally I had to do this same migration multiple times and I didn't bother mixing classic WebForms with MVC in the same application using Areas or some other techniques. At the end of the day it might turn into a nightmare trying to make those two exist together. It's always one of the two: I have the budget and I rewrite from scratch properly or I don't have the budget and I do the new stuff properly using ASP.NET MVC and try to interact with the existing application.
I find it easier to simply start a separate MVC application which depending on the interaction I am looking for would use different methods for integrating functionality from the existing WebForms application.
I am not quite familiar with the complexity and details of your scenario so it is difficult to provide an objective answer but the possibility of continuing to write new code based on the existing WebForms server side controls and not doing any MVC at all for this project might also be a good solution. Writing a new application on ASP.NET MVC just for the sake of it might not always be the best choice.

Is ASP.NET MVC flexible?

Can it easily be combined with jQuery, (ASP.NET) Ajax, ASP.NET webforms, other frameworks.
What about pulling dynamic code from ASP.NET MVC into for example classic ASP?
Does the MVC model mean that it is easy to customize code?
Background:
I have some experience that it can lead to problems to integrate frameworks relying on JavaScript with each other?
We have a classic ASP where we write new stuff in ASP.NET, and include .aspx code in the ASP files.
I am looking for some OS frameworks for stuff we need, and i think MVC based ones should be easier to adopt (KIGG)
ASP.NET MVC ships with jQuery as the default javascript framework, so no worries there. There aren't really any ties in the framework itself to jQuery so you could also switch it out with a framework of your choice. MVC comes with it's own AJAX implementation that builds on the base ASP.NET Ajax implementation (at least in javascript), so there is AJAX support but I think you'll find that it's different -- no UpdatePanels, for instance -- but you're able to do similar things.
You can mix WebForms with MVC, but you'll need to set up IgnoreRoutes for those URLs so they don't get processed. I confess that I haven't found a need to do this yet, but then I don't use third-party controls. That might be an area where, at least for now, you still need some WebForms. I've never used classic ASP and likely won't so I can't help you there.
You can use any Javascript framework with MVC, they have included Jquery as the default but any can work with it.
As far as flexibility, we have deployed a working site with ASP.NET webforms, MVC and .NET 1.1 libraries, so yes it is flexible.
In our experience ASP.NET MVC is the best thing MS have done for web development, especially if you like to control closely your html output and use web standards in your layout and design. We have used it for 6 Months and we are NEVER going back to web forms.
Have fun!

Resources