VS2013 Project routing with both WebForms, MVC and Web-api - asp.net

I use a new VS2013 project created with WebForms, MVC and Web-Api.
When using Aspx pages, they are displayed without .aspx extension.
Yes, I want to use MVC routing sometimes, and also aspx pages without any routing, but I would like to see .aspx extension.
Can I do that ? Thanks.
(In an old WebForms project I manually Added MVC fonctionnalities both webforms and mcv worked fine, so I think it's possible...)

Related

Launch an ASP MVC project from a normal .aspx page

I have an existing ASP.NET web site running on .NET 4.5. I need to integrate an ASP MVC 4 project (which is its own fully-functional web application) into it so that when the user navigates to a certain page, the ASP MVC application is launched within the page - almost as if it were in an iframe.
In the main solution I can set both as startup projects, but this is obviously not what I am looking for. Can someone point me in the direction of how to do this? I have never used WCF before, but is this something that it could be used for? Thanks for anything!
You can create a hybrid webforms - MVC application.
To do this you need to:
copy the MVC configuration from the web.config of a new MVC project to your WebForms application web.config
create the standard MVC 4 folders (at least Views, Controllers)
reference the required assemblies
copy the web.config inside Views from the MVC project to the WebForms project Views folder
change the routing configuration to ignore routes including .aspx/.ascx, so that they are handled by web forms, and not MVC (do this also for .ashx, .asmx, or whatever other web forms based artifacts)
This way you have a single ASP.NET application which supports MVC and WebForms, and use the same authentication, session, and so on.
Then you can make this kind of integrations:
- make pages that are fully MVC or fully webforms. If you're using master pages, you need to create a master page for web forms, and a layout for MVC (this can be very hard or quite easy, depending on its content and design)
- make a webforms page and integrate the MVC pages using AJAX and MVC partial views
Aprt frommy comments, this blog entry will help you a lot: Integrating ASP.NET MVC 3 into existing upgraded ASP.NET 4 Web Forms applications
By the way, this is not theoretical... I have a web application with lots of pages, areas, and views, which uses this technique, and it works flawlessly. I had to redo the design of the master page (layout and CSS) so that both kind of pages look alike. I was lucky enough to have a menu rendered in a webforms placeholder using a SQL XML query and an XSLT, so re-using it in the MVC layout was absolutely easy. You can do something similar to this in your master page and MVC layout (I mean rendering the HTML manually, and using it in both pages, so that it's done only once)
You can take some time to get it to work, but it's worth the effort.

ASP.MVC reuse ASP.NET web form

I have a custom .aspx web page that I use for browsing files on server.
Can I reuse that in MVC? Is there an easy way of doing this? ... or I have to rewrite everithing from scratch. I am prety new to mvc and the page use ajax for refreshing.
Thanks,
Radu
You have to rewrite existing pages from scratch. MVC uses completely different approach then WebForms. You can use both MVC and WebForms pages at one project, when upgrading, but can't use both approaches at one page.

How to get started with URL Routing in an asp.net webform application?

Thus far working with asp.net webforms was very easy .... But never implemented URL Routing in webforms... I know asp.net MVC Handles URL Routing pretty well...
How to get started with URL Routing in an asp.net webform application?
For EX:
Say http://www.mydomain.com/Forms/Category.aspx i want it to be like http://www.mydomain.com/Forms/Category
Any good article to start with URL Routing asp.net 3.5
Using ASP.NET Routing Without ASP.NET
MVC
Routing with ASP.NET Web Forms
Using Routing With WebForms. by Phil Hack
ASP.NET Routing
hope this helps

asp.net mvc url routing

i have a classic web project and i want to use asp.net mvc url routing just for rewrite url. is it possible without make much changes to my web project?
Routing is not part of ASP.NET MVC - it's just part of ASP.NET itself. The good news is that it works with both MVC and WebForms (ASPX files). Check out Phil Haack's blog post on how to get this to work.
The only changes you need to make to your application are to add some configuration items to web.config and then register your routes in global.asax.cs (or global.asax.vb if you're using VB).
System.Web.Routing, while shipped with ASP.NET MVC, is not technically part of the MVC framework. You can in fact use it as part of a regular ASP.NET webforms project.
Definitly possible for .net 4.0, so like in 2 months.
Also, google shows alot of content on how to do it today.
As others have said routing is now built into .net 4 and can be used for both mvc and web forms. ScottGu has a post about how to use routing in webforms and can be found here.
Hope it helps.

ASP.NET Ajax feature in existing ASP.NET website

I have a ASP.NET Website which was developed in ASP.NET 2.0.
Now I want to add a new page to the project which will make use of the ASP.NET AJAX features like Partial page updating.
Is there any options to do this ? Do i need to change any settings for this in my already existing project /Solution ?
The only problems you may run across is inside you web.config file if you don't go in and register the asp.net ajax assemblies.
Other than that you should be able to add a scriptmanager control and work with the page like any other asp.net ajax page.
Edit: Here is some documentation that should help you configure ASP.NET AJAX to an existing website.
http://www.asp.net/AJAX/documentation/live/ConfiguringASPNETAJAX.aspx
There is a great tutorial about how to implement AJAX on a regular ASP.NET web site.
http://www.asp.net/learn/ajax-videos/video-81.aspx
Hth...

Resources