0

I'm just starting to convert an existing ASP.NET Web Forms website to ASP.NET MVC. However, MVC seems excessive for some pages. ASP.NET Web Pages seems like a better fit for simple pages where the benefit of MVC is unclear.

If I use ASP.NET Web Pages for some pages and MVC for the rest, what difficulties will I likely encounter that would not occur if MVC was used for every page?

Here is one difficulty I am already aware of: Web Pages and MVC cannot share _Layout.cshtml.

EDIT

The content above was heavily edited to clarify the intent of the question.

6
  • Why not make your static pages simply .html files? If there is nothing on there for the server to process, save you and your webserver some time and processing power.
    – Tommy
    Jan 21, 2014 at 23:37
  • @Tommy: I apologize for not making this clear, but I want to use Layout pages (or something like it) to share the common HTML mark-up (site logo, menu, page header, page footer, etc.). Plus there is some dynamic content in the Layout page. Jan 22, 2014 at 14:42
  • Either MVC or WebForms will have to be processed by the server before sending to the client. I see no benefit in having a WebForms static page over a MVC static page. I (opinion) would recommend converting these on over to .cshtml pages as you can easily leverage off of routing. It sounds like you are converting from WebForms to MVC, why not make it a 100% translation/transition?
    – Tommy
    Jan 23, 2014 at 5:20
  • @Tommy: Sorry, but my original question must not be clear. I only mentioned Web Forms because that is where the site in now. I intend to eventually move the entire site away from Web Forms. The whole point of the original question is to weigh the benefits of: 1) moving the entire site to MVC versus 2) moving some of the site to MVC and the rest to Web Pages. Jan 23, 2014 at 20:09
  • I just significantly revised the wording of the question, so some of the previous comments may no longer seem relevant. Jan 27, 2014 at 18:09

3 Answers 3

0

I did a little research into this and now fully understand the scope of your question. Sorry, it was my mistake for thinking you mean Web Forms and not the relatively new Web Pages.

Any answer anyone gives here will be pretty subjective, but my take on this is to go ahead and stick to the MVC method instead of mixed modes. It appears that Web Pages is a razor based HTML file without a controller/action associated with it. If that is truly the only major difference / reason for your question, then it seems the extra three lines of code it would take to make it MVC...

public ActionResult StaticFile(){
     return View();
}

actually will make it a) easier to add dynamic data to in the future, b) more directly ties into routing (no special routes for static for example) and c) easier to interact with the server-side if you have to do any kind of authentication, session tracking, etc, etc. Anyways, my 2 cents. Go the way that works, but keep in mind the trouble/frustration of future modifications as you go forth with your site. I post this opinion with the admission of never having used Web Pages, just a few hours of reading about them.

0

The biggest pain is the maintenance of a Master Page and a __Layout view. That being said I am with Tommy - why not just make these static pages html files and not aspx pages.

1
  • I intend to use Razor with both Web Pages and MVC, so Master Pages aren't a factor in my question. Jan 22, 2014 at 19:33
0

I decided to abandon ASP.NET Web Pages and use MVC exclusively on my website. The primary reason was because of the duplication of effort for things that could not be shared between Web Pages and MVC. Here are some things I learned.

  1. Web Pages and MVC could not share _Layout pages. I was able to work around this by moving shared content into sub-layout files that the Web Page _Layout and MVC _Layout files could share.

  2. Forms authentication was no problem.

  3. I was not able to figure out how to implement MvcSiteMapProvider in the Web Pages for breadcrumb functionality. (See this question.)

The MvcSiteMapProvider difficulty made me realize that it was just a matter of time until I found something else that could not be easily shared. Therefore it seems smarter to stay with MVC rather than taking a hybrid approach.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.