I am working on a large production SAAS Webforms application that is going to be slowly migrated to MVC 5. We want to be able to let some customers 'opt-in' to the new MVC pages as they are deployed based on a configurable setting.
The MVC application will be in the same project as the webforms application. The conversion to MVC will go feature by feature to basically create a complete MVC application standing side by side with the webforms application. Once all features are implemented and customers have converted we will remove the webforms project and keep only the MVC project.
If a customer 'opts-in' then we want them to view any MVC views that exist instead of the original aspx page. If an aspx page hasn't yet been converted to MVC OR they customer has not opted-in, then we want them to view the aspx page.
My main concern is preventing the user from manually entering in a url and going to an aspx page when they should be viewing a MVC page or vice versa. Since this application is a multi-tenant system, it cannot be just set in the route configuration because those are only loaded once when the whole application starts. Whatever solution needs to dynamically check the opt-in setting for each user.
Where would be the best place to honor the 'opt-in' setting to force the user to the new MVC route instead of the legacy aspx page if both exist and what is the best way to implement this logic?
A couple of co-workers mentioned that it might could be done using a HTTPModule that checks a collection of aspx page to MVC route mappings.
Basically:
If optInToMvcSetting == true && url.contains(".aspx") Then redirect to corresponding route found in aspxToRouteMap.
If optInToMvcSettings == false && !url.contains(".aspx") Then redirect to corresponding aspx page found in aspxToRouteMap.
Does anyone have any thoughts or advice?
Why not use both?
Leave the WebForms aspx pages as is and then add the MVC routes as features are converted.
Then you can simply maintain two separate navigation renderings, one for WebForms and one for MVC. By default show WebForms but if a user opts in, show MVC. A browser cookie would be sufficient to provide this functionality.
The MVC navigation will initially include aspx links but as the conversion progresses these will be swapped out for their MVC counterparts.
The MVC routing is smart enough to distinguish between an MVC route or an aspx page.
This question contains information for your problem.
Related
I am migrating old ASP.NET WEB Form project to Angular app with ASP.NET web API.
The requirement is to merge the newly designed angular module (say login section) with old asp.net application. The new application should be functional and work together with the old ASP.NET web form project.
Now the problem I am facing is, when I log in and try to navigate to other .aspx pages, they need some session values (which old login page used to set) to work without breaking the application.
I tried to achieve this by making HTTP call to a dummy .aspx page. I passed all the session values as query parameters and set in on the server side. It's working fine.
Is it a right approach for achieving this or is there any better way? Will there be any complication later as the application grows?
In my application I have various Views and Controllers.
So naturally when one navigate through pages the URL will change based on the Controller and the View;
E.g.
http://example.com/home/index
http://example.com/account/register
http://example.com/product/newproduct
But I would like to keep the Controller and View name in the address bar secret, in other words when one would navigate, the address bar always shows http://example.com
Does anyone know how to hide these routes? I'm an using ASP.NET MVC 4 C# application.
Basically just need the server to keep track of the pages.
Unfortunately, I believe that this is not going to be an easy task to accomplish. The MVC routing engine needs certain information to deliver the request to the screen and that information is handled when you map the route. Furthermore, you can imagine the kind of trouble people could get into if the browser allowed sites to alter the address ad hoc. Take a look at this video. It's pretty good about detailing how the routing engine works Pluralsight
I have created an asp.net MVC 3 project. This project has around 200+ webpages (Views/Partial views). Listing all these links one by one will be very time consuming and tedious. So now I want enlist all link available in this project automatically on single view, so that admin(user) will have access to all links available for respective users.
Here question arises, How to get all url available for views/partial views or to controller action in asp.net MVC?
I was trying asp.net MVC route table. but I think I was trying in wrong direction.
I am updating some functionality in a classic asp website and basically to make populating a drop down happen after a value is selected in another drop down I am trying to change that page for a webform page with code behind. However, for some reason I just get the following message when attempting to go to that page:
The resource you are looking for has been removed, had its name changed, or is temporarily unavailable.
Is it possible to have the webform in this site? Is the issue something to do with IIS or caching? I don't actually have access to the server to refresh the IIS or anything so some clues about what could be happening would be useful before I go any further.
Thanks.
I just talked to someone about this and it is possible to run a webforms page in a classic asp site but the site I am working on uses a lot of session variables which are not transferred between the asp and aspx pages so it is not going to be a viable option anyway. I am going to use ajax to populate the select list.
Thanks.
We have a large existing ASP.NET WebForms application, but we are now moving over to MVC.
Rather than go through a painful process of trying to integrate MVC into the existing app, we're looking at creating a brand new VS project to completely isolate the new code.
As a first step, we are wanting to use the existing login process of the WebForms app, then redirect over to the MVC app.
Does anyone know of an easy way to do this (i.e. redirect from a WebForms project to the MVC project, in the same VS solution)? All the information I've found so far suggests either starting from scratch in MVC, or combing MVC into the existing Webforms project - neither of which is very feasible.
Many thanks,
Paul
Redirecting is the easy part: Response.Redirect("http://domain.com/mvc/home/index");. The more difficult part would be to set up a single sign on process so that when a user is authenticated on the legacy application he would be automatically authenticated on the new MVC application. Here's a nice article covering how to setup a SSO scenario between two ASP.NET applications.