Error using .Net MVC?

Microsoft Web Application Architecture Compliance ...

I wonder if I am mistaken not using .Net MVC for my new web application? I started web development in ASP Classic and moved forward with every iteration of ASP.net. I went through several months with ASP.net MVC, and I did not like some of its parts. I like routing, razor and the idea of ​​looking at specific models. But it seemed to me that my applications became too complicated after adding a few features. I feel the same is true when I look at versions of MVC applications like nopCommerce and Umbraco compared to their previous versions.

I came back and basically started writing a hybrid website / MVC. I created my own base class for "view models" that implement data annotation checking; Simple Mapper for binding form representations to models and for matching properties of objects for modeling properties and vice versa; Created extension methods and helpers for things like paging, validation, selection, and even / odd; Use controls such as repeaters, literals, and standard HTML c tags runat="server"that do not require view state.

This approach, apparently, allows me to have the best of both worlds, keeps my “Controller” code close to “View,” and everything works in the Medium Trust.

Here is a sample code:

public partial class Admin_Users_RoleAdd : System.Web.UI.Page
{
    protected class RoleAddModel : BaseModel
    {
        [Required, StringLength(100)]
        public string Name { get; set; }
        [StringLength(250)]
        public string Description { get; set; }

        public override bool Validate()
        {
            if (base.Validate() && Cortex.DB.Roles.Any(r => r.Name == Name))
                Errors["Name"] = "Already in use";
            return Errors.Count == 0;
        }
    }
    protected RoleAddModel model = new RoleAddModel();
    protected override void OnInit(EventArgs e)
    {
        if (Request.Form["Submit"].HasValue())
        {
            SimpleMapper.FormMap<RoleAddModel>(model);
            if (model.Validate())
            {
                var entity = new Role();
                SimpleMapper.Map<RoleAddModel, Role>(model, entity);
                Cortex.DB.Roles.AddObject(entity);
                Cortex.DB.SaveChanges();
                Response.Redirect("Roles.aspx");
            }
        }
        base.OnInit(e);
    }
}

And "View":

<h1>Add Role</h1>

    <div id="MainForm" class="form">
        <%= model.GetErrorMessage("Error") %>
        <form action="<%= Request.RawUrl %>" method="post">
            <div class="formField">
                <label for="Name">Name</label> <%= model.GetErrorMessage("Name") %><br />
                <input type="text" name="Name" value="<%: model.Name %>" class="required" maxlength="100" />                
            </div>
            <div class="formField">
                <label for="Description">Description</label> <%= model.GetErrorMessage("Description") %><br />
                <textarea rows="8" cols="40" name="Description" maxlength="250"><%: model.Description %></textarea>             
            </div>
            <div class="buttons">
                <input type="submit" name="Submit" value="Create" class="primary" />
                <a href="Roles.aspx">Back</a>
            </div>
        </form>
    </div>

? , , - , VWD Express .

+5
5

Microsoft MVC; , , , , , (, ).

, , , , , , Microsoft.

, , - - MVC, . ( )

UI MVC MS MVC . . , , , MVC .

, , , AuthorizeAttribute, , .

?

, . , , , . , , - . , , .

, , , , IP, . , , "" IP-, . , , . , .

+2

, , - , , . . , , , , MVC XML- .

+2

, . , , , .

. 95% .

, , , - .

, , MVC- . . , .

MVC, - fubumvc spring.net

0

, , - , ASP .Net WebForms, , , .NET WebForms MVC!

0

.

, , : .

, ASP.NET, . , HTML , , , , MVC - () , , . Plus MVC -, ASP.NET. Ruby on Rails - - COC-. MVC ...

0

All Articles