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.
Related
I want to build a new web site for a construction company. so i find some powerful web templates that support the same business area, such as :-
http://www.templatemonster.com/demo/53844.html
http://www.templatemonster.com/demo/52718.html
now as i am a web developer i can easily update these templates to contain our content. but i need to have a CMS to allow non-IT users to edit the web site. so after doing some search i settle on using Orchard CMS ,, but i need some help in answering these questions:-
i think the main challenge in my case will be to map these web templates inside Orchard.. mainly to modify the web template layout to be Orchard compatible.so my first question is if it supported to have these general web templates to work with Orchard CMS?
second question ,, will there be some limitations when mapping web templetes to be managed inside Orchard CMS.. for example will some UI components stop working?
can some one provide links on how to map web templates inside Orachrd?
since Orchard is based on asp.net mvc. now if i create a new asp.net mvc5 web application, i can easily have these web templates mapped inside my project . this includes modifying the asp.net mvc _layout view and adding the related css & JavaScript.. so is the process to map a web template inside Orcahrd similar to the process of mapping a web template inside a standard asp.net mvc web application ?
Thanks in advance for any help.
Have a look to 1.9. It has this new Templates for pages. SO you could create templates with elements already placed and then users can customise them with data.
You can do it with Widgets too, but requires a bit more admin knowledge... not much.
You could also create a module to hide any functionality behind an as-simple-as-needed UI.
start here: Orchard Docs.
If you are a web developer, start looking at the code and after you get all the Orchard 'aaaahhh' moments, you'll be alright.
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...)
I have a big website/application coded in Classic ASP, ASP.NET and ASP.NET MVC.
I have a menu on top with a lot of HTML CSS JS, and some conifiguration (visible or not ...)
and lot of dynamic links.
So the problem is when i have to update the menu i have to update 3 files, one Include in Classic ASP, one ASCX user control in asp.net and one Partial view in asp.NET MVC
I hate code duplication, so is it possible to use only one component ?
I heared about Com but i have no idea where to start.
Thanks for help
Edit : I am thinking know to use a .net Object, that can generate a string containing all the html that i need and then put it in the views MVC and in the asp.net pages
But how to use it in Classic ASP?
There's nothing stopping you using a webapi controller to expose this functionality; the webapi controller would return json or xml menu structure to the client browser this in turn would be rendered using by injection of the json over into the browser DOM and styled using CSS.
Classic ASP and MVC ASP.NET would use the same javascript and css.
I'm also working in a legacy application that is very much similar to your case, how bad the life is :(
I'll go for XML/XSLT in your case.
I'll create an XML file that contains all the menu details and use XSLT to generate HTML from XML. I can easily use the XML and XSLT in all the three technologies. So every time you need a change you have to change either the XML or XSLT file.
You can even create a simple .NET component that uses the XML/XSLT approach which could be easily used in ASP.NET Web Forms, ASP.NET MVC (in custom view engine?) and in classic asp as well (you have to register).
Guess, you can make an action method in asp.net MVC to render the dynamic menu and do AJAX load from the javascript in every part of the site?
UPDATE:
You can make an HTTP GET request in classic ASP to the aforementioned ASP.NET MVC handler, and cache results if its not very dynamic. Anyway it should be pretty fast if its within the same server. I suppose, request will look like in this answer
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.
Is there any way to use something like BlogEngine.NET (a blogging framework developed on the ASP.NET web forms model) in an ASP.NET MVC application? I want something where I can simply go to http://rooturl/blog and have it fire up the BlogEngine.NET site. I'm assuming that the ASP.NET MVC framework will intercept this call however and try to route it to the "BlogController"'s Index function though. Is there any way around this or is this a non-issue?
Scott Hanselman wrote on this a while back:
Plug-In Hybrids: ASP.NET WebForms and ASP.MVC and ASP.NET Dynamic Data Side By Side
But if I recall correctly, if you don't have a controller that matches /blog then the engine will default to sending the request to your /blog folder, and away you go, on top of that, as Scott notes:
Why doesn't ASP.NET MVC grab the request? Two reasons. First, there's an option on RouteCollection called RouteExistingFiles. It's set to false by default which causes ASP.NET MVC to automatically skip routing when a file exists on disk.
However, he goes on to note that you could just add the following at the top of your route definitions:
routes.IgnoreRoute("blog/{*pathInfo}");
Which would then ignore all requests to /blog/