Category: MVC

Area in MVC

What is Area in MVC. ASP.NET MVC 2 introduced Area. Area allows us to partition large application into smaller units where each unit contains separate MVC folder structure, same as default MVC folder structure Read more →

Apicontroller and controller differences

ASP.NET MVC public class TweetsController : Controller { // GET: /Tweets/ [HttpGet] public ActionResult Index() { return Json(Twitter.GetTweets(), JsonRequestBehavior.AllowGet); } } ASP.NET Web API public class TweetsController : ApiController { // GET: /Api/Tweets/ public List<Tweet> Get() { return Twitter.GetTweets(); } } The first major difference you will notice is that actions on Web API controllers do not return views, they… Read more →

updated questions in .Net topic

— Check if my model is valid from inside the razor view? Gets the model state dictionary object that contains the state of the model and of model-binding validation. if (ModelState.IsValid){} —write validation in view <div> @using (Html.BeginForm(“Create”, “Client”, FormMethod.Post, new { @class = “form-horizontal”, role = “form” })) { <div> <div>@Html.LabelFor(m => m.Name) <span>@Html.ValidationMessageFor(model => model.Name)</span></div> <div>@Html.TextBoxFor(m => m.Name,… Read more →

updated topic discussion in Mvc

—Route table,Action filter ,validation  and Budling(how to use or call) protected void Application_Start() { AreaRegistration.RegisterAllAreas();//Registers all the areas in ASP.NET MVC. //GlobalFilters.Filters.Add(new HandleErrorAttribute()); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters) ; RouteConfig.RegisterRoutes(RouteTable.Routes); BundleConfig.RegisterBundles(BundleTable.Bundles); //RegisterGlobalFilters(GlobalFilters.Filters); } ///Route class defined in app_start folder .it is config file. public class RouteConfig { public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute(“{resource}.axd/{*pathInfo}”);   // routes.MapRoute( //   name: “Default”, //   url: “{controller}/{action}/{id}”, //                   … Read more →

Mvc Scenario based discussion

MVC– 1)definition: it is framework that splits an application’s implementation logic into three component roles: –Model->work as business logic and storage mechanism to store the data. Entity framework work in this component. view ->it is user interface logic to which user direct interact in this component. Asp. Net and Razor use in view component. controller->it is handle the request from… Read more →