0

I was wondering if anyone had any experience using a webform page with a MVC MasterPage or even better a Razor _Layout page.

The company wants to convert to MVC but they don't want to feel any pain and they want to be able to retro fit their old pages very easily. After the typical grumbling about investment in infrastructure and extensibility I realize that I need to get them on the platform and then work them into the modern era slowly. It's not optimal but it's a foot in the door.

So what I'm hoping is that I can build there masterpage ( header, menu, footer ) into MVC ( actually already have ) and then remove the masterpage from their webform pages and load them in the MVC layout or masterpage.

I figure I can do that with ajax, but I would really like to not have to write wiring for this to happen as a) they will see this as overhead and hacky ( and I agree ) and b) there are a ton of old pages and I don't want to be at it forever. Any thoughts or experiences would be appreciated, R

tereško
  • 58,060
  • 25
  • 98
  • 150
Raif
  • 8,641
  • 13
  • 45
  • 56
  • WebForms and MVC are very different approaches to web development. There really isn't a "conversion process" other than rewriting all of your pages as Views and code behind as Controllers. Some have had success [combining web forms and MVC within the same site](http://stackoverflow.com/questions/5257854/can-mvc-3-and-webforms-co-exist-on-a-website), which may be a better option as it allows you to rewrite one page at a time. – jrummell Sep 24 '12 at 15:19

2 Answers2

0

you can try use HttpHandler or HttpModule and at the end of request put section via replace("[SECTION_NAME]", getSection). In MVC you can geberate html from vew and model, but for this you need execute request to server. So i think it will be bette if you cached this part... some like that.

Anton Baksheiev
  • 2,211
  • 2
  • 14
  • 15
0

OK, so this was a fool's errand, clearly. The premise was sound, get their regular pages into an mvc masterpage then you have sufficient buy in to move forward. But it's a colossal pain in the ass and possibly not even doable. Perhaps in the future when they have assimilated WebForms in MVC, which is their plan although I can't see how it's possible or even desirable, but not now.

I got some of the way courtesy of this post. It actually loaded up the page in the MVC ( had to be webforms, not razor ) MasterPage. But when the WebForm did it's ridiculous "post back" pseudo-event thing it called the controller, rather then the page. At which point I threw up my hands and decided to go the political route rather then the back door route.

Like I said in the future this maybe possible, and if you really want to dig it may be possible today, but as the cutting and rather snide comments point out it's kind of a dumb idea to begin with.

R

Raif
  • 8,641
  • 13
  • 45
  • 56