ASP.NET MVC without ASP.NET? - 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

Related

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 :)

how can i user razor syntax in asp.net project not mvc [duplicate]

I'm liking the Razor syntax that Microsoft has developed for inline coding in their WebMatrix product (http://en.wikipedia.org/wiki/Microsoft_WebMatrix).
Now that Visual Studio SP1 has RTM'd, is it possible (and/or planned) to enable the use of Razor syntax in ASP.NET Webforms?
We (the ASP.NET team) currently have no plans to support the WebForms page model using Razor syntax. Furthermore it is unlikely that we would ever seriously consider this as the models are too different to make the two work together.
You can use Razor pages without MVC; this is called ASP.Net WebPages.
Just add .CSHTML files to a normal ASP.Net 4.0 project.
I explained how this works in my blog.
You could possibly integrate it using the RazorEngine available from Codeplex. It allows you to process razor outside of MVC. Though you don't get all the features you get from the MVC version of Razor, such as #Html and #Url and others.
I dare say that Microsoft have considered it, but there is no official word on the subject. Since you are not supposed to have C# or VB code in the ASPX file, you have to wonder about the point of adding Razor support to Web Forms. The code behind would still be a (partial) class file. You wouldn't put Razor there any more than you would put it in a class file in Web Pages or MVC. And swapping Server Controls and all that good declarative stuff for Html Helpers removes one of the key reasons for going the Web Forms route, IMO.
This really isn't that difficult to do. Working on it right now. Grab RazorEngine from CodePlex. It lets you compile Razor cshtml/vbhtml files into a class at runtime.
You can then take that class, and use it from a ASP.Net server control, inside its Render method. This is a great way to get HTML out of the body of a server control. Much, much cleaner.
Now, you can also add some methods that you can invoke from Razor. For instance, add something like RenderChild. Additionally, you could set the Server Control itself as the Model available to Razor. You could then invoke into the server control. Including doing something like grabbing one of it's child controls and invoking Render.

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.

Can we use ASP.NET MVC3 along with classic ASP.NET?

I have ASP.NET application in which some pages are designed using MVC3 architecture and some with classic ASP.NET (with view state ..etc) I want to merge these two projects in One. Or Is there any predefined Controller in MVC3 that can deal with this specific requirement?
Can we make some URL patterns to be dealt with Classic ASP.NET and some with MVC3 ?
Why YES you can!
http://www.hanselman.com/blog/IntegratingASPNETMVC3IntoExistingUpgradedASPNET4WebFormsApplications.aspx
He also has another post using a NuGet package to integrate the two...

How to add ASP.NET MVC view in 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.

Resources