Coffeehouse Thread

70 posts

Questions regarding "Web pages" vs "Web forms" vs "MVC"

Back to Forum: Coffeehouse
  • User profile image
    kettch

    @WhatDoYouMean:

    ASP.NET was originally mean to be deployed as a single piece as part of the .NET framework. However, since they are branching out to different stacks such as MVC, I think you will eventually see Web Forms seperated from System.Web and deployed as an add-on stack just like MVC.

    Razor is independant from MVC and WebMatrix. Razor is the name of the markup that both of them can use. It's just text, you don't need anything special, and you can write it in notepad if you want.

    There shouldn't be any worry about "extra add-ons" since MVC can be deployed as a self contained unit. Just make sure the server has .NET4 and use "Add Deployable Dependencies" and MVC will work just fine.

    Recommended reading: http://www.asp.net/mvc

  • User profile image
    WhatDoYou​Mean

    I am pondering this: I use MVC but I will initiate the "Models" manually and use Requests and such instead of letting it handling "everything". This way, I can "move away" from it in case of let's say "emergency".

    I mean, I like the way MVC separates stuff but I feel unease to give too much control to a Framework.

    Would that be a good way?

  • User profile image
    kettch

    @WhatDoYouMean:

    MVC is built on the principle of control, so you can replace the various pieces with anything you want. What kind of control are you worried about losing? Unless you write your own stack from scratch, you have to trust somebody else's code at some point.

  • User profile image
    blowdart

    , WhatDoYouMean wrote

    I am pondering this: I use MVC but I will initiate the "Models" manually and use Requests and such instead of letting it handling "everything". This way, I can "move away" from it in case of let's say "emergency".

    I mean, I like the way MVC separates stuff but I feel unease to give too much control to a Framework.

    Would that be a good way?

    What bits are you concerned about here? Model binding? What's the actual concern? What is your emergency scenario?

     

  • User profile image
    WhatDoYou​Mean

    Well, I didn't like the whole handling of Requests. It passes the Model "automagically". In the demo, I didn't even see anywhere, where it "initiated" as in "new bla();" so it felt very "Lightswitchy" if you know what I mean.

    Other than that, The whole separated classes "Models", Controls and Views are really nice.

    Still newbie though. Big Smile

    ps. I mean, it's nice that it handles stuff "automagically" but I feel very "locked in" that way because once the project grows and I get use to it, there is no way it can be "moved" to say PHP or something else in case of "emergency".

  • User profile image
    MasterPi

    @WhatDoYouMean: How are you instantiating the models manually? (your nickname is very appropriate ha!)

    The thing is, the more you stay within the framework, the more automatic a lot of stuff is that you would have to worry about otherwise. I would look at more tutorials before you decide to jump ship on conventions, etc. Obviously, you should break out of it when the solution is something incredibly long winded, confusing, impractical. But do give it some thought.

  • User profile image
    WhatDoYou​Mean

    @MasterPie:I don't instantiate anything. I'm just testing the demo which VSX creates really. It seems that they are all done "magically". I don't see the code anywhere. That's my worry. It's too as I mentioned above "lightswitchy". ( If that's a word. hehe )

  • User profile image
    blowdart

    , WhatDoYouMean wrote

    Well, I didn't like the whole handling of Requests. It passes the Model "automagically". In the demo, I didn't even see anywhere, where it "initiated" as in "new bla();" so it felt very "Lightswitchy" if you know what I mean.

    Which is a good thing, honest Smiley You can control model binding with custom binders, but frankly it's rare you'll need too.You can limit the fields that get bound to models (and you shoud) with [Bind(Include)] or [Bind(Exclude)].

    However I've not saying use your data models for binding (or EF models, or whatever). I use view models to limit what a view gets to what the view needs.

  • User profile image
    ZippyV

    You can write your own modelbinder if you want.

  • User profile image
    WhatDoYou​Mean

    Here is an example:

    <% using (Html.BeginForm()) { %>                   

    <%: Html.LabelFor(m => m.OldPassword) %>

    I mean, what the heck is that? and it gets handled "automagically" in the Controller class. No fetching of data via the "Request" etc.

    That's why I feel the unease of "lightswitch" in this.

  • User profile image
    MasterPi

    But in really any dev environment, a LOT of things are instantiated automagically without you knowing...you're still working in some framework (unless you're writing assembly, but then that might not be true either).

  • User profile image
    WhatDoYou​Mean

    Any sources where I can read up on how to make a custom modelbinder?

    Then again, why not just use "Request"? Isn't it easier and more stright forward specially if you want to be able to "leave" the platform and not lock yourself into this too much?

  • User profile image
    blowdart

    , WhatDoYouMean wrote

    Here is an example:

    <% using (Html.BeginForm()) { %>                   

    <%: Html.LabelFor(m => m.OldPassword) %>

    I mean, what the heck is that? and it gets handled "automagically" in the Controller class. No fetching of data via the "Request" etc.

    That's why I feel the unease of "lightswitch" in this.

    That begins a form, then displays an HTML <label> for the old password field/property in the model.

    There is no concept of Request in views.

  • User profile image
    blowdart

    , WhatDoYouMean wrote

    Any sources where I can read up on how to make a custom modelbinder?

    Then again, why not just use "Request"? Isn't it easier and more stright forward specially if you want to be able to "leave" the platform and not lock yourself into this too much?

    No. Your views don't need a request. You don't need to parse requests into lists yourself? Why reinvent the wheel? If you want to leave the platform, well, you're going to have to rewrite all the request/response code anyway. False economy.

     

  • User profile image
    WhatDoYou​Mean

    @MasterPie:Yeah I understand but like, if I don't even instantiate my classes then it feels like I'm not having the control and as I said, I am scared of this because it's very "specialized" to Microsoft MVC and my code wouldn't be able to "move out of it" with ease in case I want to be moved to PHP. ( Theoretically of course. I like C#. )

  • User profile image
    WhatDoYou​Mean

    @blowdart: Parsing requests is exactly what I need to do because in case I need to move this thing out of MVC into PHP, it would make it MUCH harder to understand the code because frankly, there isn't much "coding" going on in that Demo atleast.

  • User profile image
    MasterPi

    @WhatDoYouMean: Well, like blowdart said up above, you'll rewrite it all anyway if you're leaving the platform entirely (to PHP?).

    But, if you wrote code in tiers, and had a business layer + data layer containing all of your business objects (reference them in your models), treating the MVC application as just a client app that consumes your business objects, then you get the flexibility to "move" when you need to. Just construct a new "web forms" application that consumes the layers you had before.

  • User profile image
    WhatDoYou​Mean

    Just for the record, I DO like this whole MVC thing but I dislike the lock-in potential of it and having seen where Microsoft is headed with Windows 8, as mentioned in my other threads here, I am VERY scared and I really mean it. So I will continue to use Microsoft technology but I will do my best to not get too much lock-in.

    There is a personal line there which no corporation is allowed to cross.

    ps. I DO like Microsoft technologies. Been a fan for years. Smiley

Comments closed

Comments have been closed since this content was published more than 30 days ago, but if you'd like to continue the conversation, please create a new thread in our Forums, or Contact Us and let us know.