How to add ASP.NET MVC view in ASP.NET? - asp.net

I have an ASP.NET MVC view which contains some plain html. I wanna use this this same view in asp.net. How can i do this?? is this possible?
I am developing an application which contains both ASP.NET MVC and ASP.NET. So i wanna use the same usercontrol accross the application.
Can anyone provide some link/suggestions for the same.

An ASP.NET MVC View relies on HTML helpers which are not available in a normal ASP.NET application. Ideally an ASP.NET MVC view should be served by a controller. On the other hand an ASP.NET webform contains usercontrols and relies on postpack and viewdata which are not available in ASP.NET MVC.
You may take a look at this article about mixing ASP.NET MVC and classic ASP.NET.

So, what's the problem - just put your markup into 'ascx' user control or you could even use WebControl and use it across the app. It does work perfectly for both WebForms and MVC. Just make sure you are not trying to access to any incompatible features - in other words, use just a ASP.NET platform features which are not specific to WebForms or MVC. But since you mentioned it would be just a plain html without any postbacks, MVC helpers, etc. there should not be any issues.

Related

what Parameters needs to considered while moving webform model to MVC pattern of ASP.NET framework?

I have gone all over internet however still confuse in choosing MVC or WEBform pattern of ASP.NET Framework.
i have an application which is Developed on Webform model, does it really require to move it to MVC?
Webform is quiet stable, why should we go for MVC?
I mean what parameters we need to consider before moving webform model project to MVC?
any help or redirection will be highly appreciated.
Thanks!
As mentioned in the comments, there is nothing special that forces you to move into MVC.
If you’re going to start a new project consider using MVC. Here are few points which you could get benefited while using ASP.NET MVC :
Asp.Net MVC is a lightweight and follow MVC (Model, View, Controller) pattern based development model.
Asp.Net MVC has html helpers.
Asp.Net MVC does not support view state. Asp.Net MVC has route-based URLs means URLs are divided into controllers and
actions and moreover it is based on controller not on physical
file.
Asp.Net MVC follow customizable syntax (Razor as default)
In Asp.Net MVC, Views and logic are kept separately.
Asp.Net MVC has Layouts for consistent look and feels.
Asp.Net MVC has Partial Views for code re-usability.
Asp.Net MVC is lightweight, provide full control over markup and support many features that allow fast & agile development. Hence it
is best for developing interactive web application with latest web
standards.
Asp.Net Web MVC is Open Source.

Posting data from mvc view to a webform in the same MVC project

I have an MVC project that needs to use SSRS for reporting. For this reason my MVC project now has a webform that holds the reportviewer control. From my MVC page I now need to pass certain parameters to the webform. What is the recommended way to do this? I’m not sure I want to use sessions for this purpose unless it is the recommended way. How do I post from the mvc view to the web form? I don’t think I can call it by controller name as the web form has no controller.
Please help.
In the past, I have maintained a legacy system that used the webform for report generated and an ASP.NET MVC in the new pages. I found out only one way to do that is using the Session to communicate between the webform and the ASP.NET MVC pages. So any other approaches will be welcome :)

ASP.NET ScriptControl & ASP.NET MVC 3

I'm not familiar with ASP.NET MVC 3 (and more general with the ASP.NET MVC). I can not find any information whether it is possible to use my ScriptControl in ASP.NET MVC 3 project. The ScriptControl was implemented for my previous project in ASP.NET WebForms?
It's more common to use jquery.unobtrusive-ajax.js intead of ScriptManager scripts to use ajax and it's more powerfull to use bundle (only for Mvc4) instead of ScriptManager to manage script links for different configurations and also to minify combine, control caching etc
Yes you can use it. Instead of creating a new page in MVC 3 using Razor, use asp.net web pages for your view.
Although its not recommended. Do it, if you are too desperate.

Web forms within an ASP.NET MVC project?

I need to add an "Admin" Area to an ASP.NET MVC project, and I need it to use ASP.NET Web Forms, not MVC.
Can ASP.NET Web Forms be used in an ASP.NET MVC application?
I have something similar in an MVC project because we had to use some 3rd party controls on a page. So what we did was this:
In the RegisterRoutes in global.asax.cs add:
routes.IgnoreRoute("WebForms/*/{resource}.aspx/{*pathInfo}");
And add your webforms stuff to the WebForms directory (obviously you can change that to whatever you need, so long as it doesn't clash with any of your MVC routes.
I think that was about it. Other than being a really horrible kludge.
It is possible to mix ASP.NET WebForms and MVC in the same project. Scott Hanselman had a post about this back in 2008:
Plug-In Hybrids: ASP.NET WebForms and ASP.MVC and ASP.NET Dynamic Data Side By Side

ASP.NET MVC without ASP.NET?

As far as I know, ASP.NET MVC leverages a lot of the features of ASP.NET Web Forms, one of these services is how to get the Html response from the template .aspx file (the view). Can asp.net mvc leverages any other platform to generate html over template files (something like PHP for example)?
EDIT: There is NO use case for this, just curiosity!
Yes, it can! The aspx model is just one of the view template mechanisms. There are others - you can even write your own. The key here is IViewEngine, with WebFormViewEngine being the aspx/ascx provider. ASP.NET MVC In Action covers some of this in chapter 6 "Customizing & Extending the ASP.NET MVC Framework".
you can use other ViewEngines
Spark
NHaml

Resources