0

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.

2 Answers 2

3

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.

Sign up to request clarification or add additional context in comments.

2 Comments

so i am adding all the html's in a usercontrol(ascx). Can i use this in asp.net application somehow???
so what is the best practice to have usercontrol in a single location which can be served both by ASP.NET MVC and ASP.NET? Moreover this user control is nothing but html, no server side codes for the same in ASP.NET
1

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.