{"id":216,"date":"2014-08-22T12:54:30","date_gmt":"2014-08-22T12:54:30","guid":{"rendered":"http:\/\/mairwa.com\/wordpress\/?p=216"},"modified":"2014-08-22T12:54:30","modified_gmt":"2014-08-22T12:54:30","slug":"updated-topic-discussion-in-mvc","status":"publish","type":"post","link":"http:\/\/mairwa.com\/wordpress\/?p=216","title":{"rendered":"updated topic discussion in Mvc"},"content":{"rendered":"<p><b>&#8212;Route table,Action filter ,validation \u00a0and Budling(how to use or call)<\/b><\/p>\n<p>protected void Application_Start()<\/p>\n<p>{<\/p>\n<p>AreaRegistration.RegisterAllAreas();\/\/Registers all the areas in ASP.NET MVC.<\/p>\n<p>\/\/GlobalFilters.Filters.Add(new HandleErrorAttribute());<\/p>\n<p>FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters) ;<\/p>\n<p>RouteConfig.RegisterRoutes(RouteTable.Routes);<\/p>\n<p>BundleConfig.RegisterBundles(BundleTable.Bundles);<\/p>\n<p>\/\/RegisterGlobalFilters(GlobalFilters.Filters);<\/p>\n<p>}<\/p>\n<p><b>\/\/\/Route class defined in app_start folder .it is config file.<\/b><\/p>\n<p>public class RouteConfig<\/p>\n<p>{<\/p>\n<p>public static void RegisterRoutes(RouteCollection routes)<\/p>\n<p>{<\/p>\n<p>routes.IgnoreRoute(&#8220;{resource}.axd\/{*pathInfo}&#8221;);<\/p>\n<p>&nbsp;<\/p>\n<p>\/\/ routes.MapRoute(<\/p>\n<p>\/\/\u00a0\u00a0 name: &#8220;Default&#8221;,<\/p>\n<p>\/\/\u00a0\u00a0 url: &#8220;{controller}\/{action}\/{id}&#8221;,<\/p>\n<p>\/\/\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 defaults: new { controller = &#8220;Home&#8221;, action = &#8220;Index&#8221;, id = UrlParameter.Optional }<\/p>\n<p>\/\/);<\/p>\n<p>routes.MapRoute(<\/p>\n<p>name: &#8220;Default&#8221;,<\/p>\n<p>url: &#8220;{controller}\/{action}\/{id}&#8221;,<\/p>\n<p>defaults: new { controller = &#8220;Account&#8221;, action = &#8220;Login&#8221;, id = UrlParameter.Optional }<\/p>\n<p>);<\/p>\n<p>}<\/p>\n<p>}<\/p>\n<p>}<\/p>\n<p><b>&#8212;Bundling class call global.asax but define in app_start folder .it is config file.<\/b><\/p>\n<p>&nbsp;<\/p>\n<p>public class BundleConfig{<\/p>\n<p>public static void RegisterBundles(BundleCollection bundles)<\/p>\n<p>{<\/p>\n<p>bundles.Add(new ScriptBundle(&#8220;~\/bundles\/jquery&#8221;).Include(<\/p>\n<p>&#8220;~\/Scripts\/jquery-2.0.3.js&#8221;,<\/p>\n<p>&#8220;~\/Scripts\/Aplication.js&#8221;,<\/p>\n<p>&#8220;~\/Scripts\/jquery.inputmask-2.2.17.min.js&#8221;));<\/p>\n<p>&nbsp;<\/p>\n<p>bundles.Add(new ScriptBundle(&#8220;~\/bundles\/jqgrid&#8221;).Include(<\/p>\n<p>&#8220;~\/Scripts\/i18n\/grid.locale-en.js&#8221;,<\/p>\n<p>&#8220;~\/Scripts\/jquery.jqGrid.min.js&#8221;,<\/p>\n<p>&#8220;~\/Scripts\/jquery.linq.min.js&#8221;));<\/p>\n<p>bundles.Add(new ScriptBundle(&#8220;~\/bundles\/jqueryval&#8221;).Include(<\/p>\n<p>&#8220;~\/Scripts\/jquery.validate*&#8221;));<\/p>\n<p>&nbsp;<\/p>\n<p>\/\/ Use the development version of Modernizr to develop with and learn from. Then, when you&#8217;re<\/p>\n<p>\/\/ ready for production, use the build tool at http:\/\/modernizr.com to pick only the tests you need.<\/p>\n<p>bundles.Add(new ScriptBundle(&#8220;~\/bundles\/modernizr&#8221;).Include(<\/p>\n<p>&#8220;~\/Scripts\/modernizr-*&#8221;));<\/p>\n<p>&nbsp;<\/p>\n<p>bundles.Add(new ScriptBundle(&#8220;~\/bundles\/bootstrap&#8221;).Include(<\/p>\n<p>&#8220;~\/Scripts\/bootstrap.js&#8221;,<\/p>\n<p>&#8220;~\/Scripts\/respond.js&#8221;));<\/p>\n<p>&nbsp;<\/p>\n<p>bundles.Add(new StyleBundle(&#8220;~\/Content\/css&#8221;).Include(<\/p>\n<p>&#8220;~\/Content\/bootstrap.css&#8221;,<\/p>\n<p>&#8220;~\/Content\/Jq DatePicker\/css\/jquery.ui.datepicker.css&#8221;,<\/p>\n<p>&#8220;~\/Content\/site.css&#8221;,<\/p>\n<p>&#8220;~\/Content\/jquery.jqGrid\/ui.jqgrid.css&#8221;,<\/p>\n<p>&#8220;~\/Content\/Grid.css&#8221;,<\/p>\n<p>&#8220;~\/Content\/themes\/base\/jquery-ui.css&#8221;));<\/p>\n<p>&nbsp;<\/p>\n<p>bundles.Add(new ScriptBundle(&#8220;~\/bundles\/jqueryDatePicker&#8221;).Include(<\/p>\n<p>&#8220;~\/Scripts\/jquery.ui.core.js&#8221;,<\/p>\n<p>&#8220;~\/Scripts\/jquery.ui.widget.js&#8221;,<\/p>\n<p>&#8220;~\/Scripts\/jquery.ui.datepicker.js&#8221;<\/p>\n<p>));<\/p>\n<p>&nbsp;<\/p>\n<p>}<\/p>\n<p>}<\/p>\n<p><b>&#8212;Action Filter<\/b><\/p>\n<p>\/\/ Summary:<\/p>\n<p>\/\/\u00a0\u00a0\u00a0\u00a0 Represents the base class for filter attributes.<\/p>\n<p>[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, Inherited = true, AllowMultiple = false)]<\/p>\n<p>public abstract class ActionFilterAttribute : FilterAttribute, IActionFilter, IResultFilter<\/p>\n<p>{<\/p>\n<p>\/\/ Summary:<\/p>\n<p>\/\/\u00a0\u00a0\u00a0\u00a0 Initializes a new instance of the System.Web.Mvc.ActionFilterAttribute class.<\/p>\n<p>protected ActionFilterAttribute();<\/p>\n<p>&nbsp;<\/p>\n<p>\/\/ Summary:<\/p>\n<p>\/\/\u00a0\u00a0\u00a0\u00a0 Called by the ASP.NET MVC framework after the action method executes.<\/p>\n<p>\/\/<\/p>\n<p>\/\/ Parameters:<\/p>\n<p>\/\/\u00a0\u00a0 filterContext:<\/p>\n<p>\/\/\u00a0\u00a0\u00a0\u00a0 The filter context.<\/p>\n<p>public virtual void OnActionExecuted(ActionExecutedContext filterContext);<\/p>\n<p>\/\/<\/p>\n<p>\/\/ Summary:<\/p>\n<p>\/\/\u00a0\u00a0\u00a0\u00a0 Called by the ASP.NET MVC framework before the action method executes.<\/p>\n<p>\/\/<\/p>\n<p>\/\/ Parameters:<\/p>\n<p>\/\/\u00a0\u00a0 filterContext:<\/p>\n<p>\/\/\u00a0\u00a0\u00a0\u00a0 The filter context.<\/p>\n<p>public virtual void OnActionExecuting(ActionExecutingContext filterContext);<\/p>\n<p>\/\/<\/p>\n<p>\/\/ Summary:<\/p>\n<p>\/\/\u00a0\u00a0 \u00a0\u00a0Called by the ASP.NET MVC framework after the action result executes.<\/p>\n<p>\/\/<\/p>\n<p>\/\/ Parameters:<\/p>\n<p>\/\/\u00a0\u00a0 filterContext:<\/p>\n<p>\/\/\u00a0\u00a0\u00a0\u00a0 The filter context.<\/p>\n<p>public virtual void OnResultExecuted(ResultExecutedContext filterContext);<\/p>\n<p>\/\/<\/p>\n<p>\/\/ Summary:<\/p>\n<p>\/\/\u00a0\u00a0\u00a0\u00a0 Called by the ASP.NET MVC framework before the action result executes.<\/p>\n<p>\/\/<\/p>\n<p>\/\/ Parameters:<\/p>\n<p>\/\/\u00a0\u00a0 filterContext:<\/p>\n<p>\/\/\u00a0\u00a0\u00a0\u00a0 The filter context.<\/p>\n<p>public virtual void OnResultExecuting(ResultExecutingContext filterContext);<\/p>\n<p>}<\/p>\n<p>&#8211;Use of View(also include validation,Beginform\u00a0 ,jquery call and jquery call)<b><\/b><\/p>\n<p>@model TypeSettingWeb.Models.RegisterViewModel<\/p>\n<p>@{<\/p>\n<p>ViewBag.Title = &#8220;Register&#8221;;<\/p>\n<p>}<\/p>\n<p>&nbsp;<\/p>\n<p>&lt;h2&gt;@ViewBag.Title.&lt;\/h2&gt;<\/p>\n<p>&nbsp;<\/p>\n<p>@using (Html.BeginForm(&#8220;Register&#8221;, &#8220;Account&#8221;, FormMethod.Post, new { @class = &#8220;form-horizontal&#8221;, role = &#8220;form&#8221; }))<\/p>\n<p>{<\/p>\n<p>@Html.AntiForgeryToken()<\/p>\n<p>&lt;h4&gt;Create a new account.&lt;\/h4&gt;<\/p>\n<p>&lt;hr \/&gt;<\/p>\n<p>@Html.ValidationSummary()<\/p>\n<p>&lt;div&gt;<\/p>\n<p>@Html.LabelFor(m =&gt; m.UserName, new { @class = &#8220;col-md-2 control-label&#8221; })<\/p>\n<p>&lt;div&gt;<\/p>\n<p>@Html.TextBoxFor(m =&gt; m.UserName, new { @class = &#8220;form-control&#8221; })<\/p>\n<p>&lt;\/div&gt;<\/p>\n<p>&lt;\/div&gt;<\/p>\n<p>&lt;div&gt;<\/p>\n<p>@Html.LabelFor(m =&gt; m.Password, new { @class = &#8220;col-md-2 control-label&#8221; })<\/p>\n<p>&lt;div&gt;<\/p>\n<p>@Html.PasswordFor(m =&gt; m.Password, new { @class = &#8220;form-control&#8221; })<\/p>\n<p>&lt;\/div&gt;<\/p>\n<p>&lt;\/div&gt;<\/p>\n<p>&lt;div&gt;<\/p>\n<p>@Html.LabelFor(m =&gt; m.ConfirmPassword, new { @class = &#8220;col-md-2 control-label&#8221; })<\/p>\n<p>&lt;div&gt;<\/p>\n<p>@Html.PasswordFor(m =&gt; m.ConfirmPassword, new { @class = &#8220;form-control&#8221; })<\/p>\n<p>&lt;\/div&gt;<\/p>\n<p>&lt;\/div&gt;<\/p>\n<p>&lt;div&gt;<\/p>\n<p>&lt;div&gt;<\/p>\n<p>&lt;input type=&#8221;submit&#8221; value=&#8221;Register&#8221; \/&gt;<\/p>\n<p>&lt;\/div&gt;<\/p>\n<p>&lt;\/div&gt;<\/p>\n<p>}<\/p>\n<p>&nbsp;<\/p>\n<p>@section Scripts {<\/p>\n<p>@Scripts.Render(&#8220;~\/bundles\/jqueryval&#8221;)<\/p>\n<p>}<\/p>\n<p><b>\/\/\/Validation class<\/b><\/p>\n<p>public class RegisterViewModel<\/p>\n<p>{<\/p>\n<p>[Required]<\/p>\n<p>[Display(Name = &#8220;User name&#8221;)]<\/p>\n<p>public string UserName { get; set; }<\/p>\n<p>&nbsp;<\/p>\n<p>[Required]<\/p>\n<p>[StringLength(100, ErrorMessage = &#8220;The {0} must be at least {2} characters long.&#8221;, MinimumLength = 6)]<\/p>\n<p>[DataType(DataType.Password)]<\/p>\n<p>[Display(Name = &#8220;Password&#8221;)]<\/p>\n<p>public string Password { get; set; }<\/p>\n<p>&nbsp;<\/p>\n<p>[DataType(DataType.Password)]<\/p>\n<p>[Display(Name = &#8220;Confirm password&#8221;)]<\/p>\n<p>[Compare(&#8220;Password&#8221;, ErrorMessage = &#8220;The password and confirmation password do not match.&#8221;)]<\/p>\n<p>public string ConfirmPassword { get; set; }<\/p>\n<p>}<\/p>\n<p><b>&#8211;Actionlink uses<\/b><\/p>\n<p>&nbsp;<\/p>\n<p>&#8212; \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \/\/<\/p>\n<p>\/\/ Summary:<\/p>\n<p>\/\/\u00a0\u00a0\u00a0\u00a0 Returns an anchor element (a element) that contains the virtual path of the<\/p>\n<p>\/\/\u00a0\u00a0\u00a0\u00a0 specified action.<\/p>\n<p>\/\/<\/p>\n<p>\/\/ Parameters:<\/p>\n<p>\/\/\u00a0\u00a0 htmlHelper:<\/p>\n<p>\/\/\u00a0\u00a0\u00a0\u00a0 The HTML helper instance that this method extends.<\/p>\n<p>\/\/<\/p>\n<p>\/\/\u00a0\u00a0 linkText:<\/p>\n<p>\/\/\u00a0\u00a0\u00a0\u00a0 The inner text of the anchor element.<\/p>\n<p>\/\/<\/p>\n<p>\/\/\u00a0\u00a0 actionName:<\/p>\n<p>\/\/\u00a0\u00a0\u00a0\u00a0 The name of the action.<\/p>\n<p>\/\/<\/p>\n<p>\/\/\u00a0\u00a0 routeValues:<\/p>\n<p>\/\/\u00a0\u00a0\u00a0\u00a0 An object that contains the parameters for a route.<\/p>\n<p>\/\/<\/p>\n<p>\/\/ Returns:<\/p>\n<p>\/\/\u00a0\u00a0\u00a0\u00a0 An anchor element (a element).<\/p>\n<p>\/\/<\/p>\n<p>\/\/ Exceptions:<\/p>\n<p>\/\/\u00a0\u00a0 System.ArgumentException:<\/p>\n<p>\/\/\u00a0\u00a0\u00a0\u00a0 The linkText parameter is null or empty.<\/p>\n<p>public static MvcHtmlString ActionLink(this HtmlHelper htmlHelper, string linkText, string actionName, RouteValueDictionary routeValues);<\/p>\n<p>&nbsp;<br \/>\narchitecture using in mvc<br \/>\njson<br \/>\nrepository<\/p>\n<p><b><i>\u00a0<\/i><\/b><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p class=\"excerpt\">&#8212;Route table,Action filter ,validation \u00a0and 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(&#8220;{resource}.axd\/{*pathInfo}&#8221;); &nbsp; \/\/ routes.MapRoute( \/\/\u00a0\u00a0 name: &#8220;Default&#8221;, \/\/\u00a0\u00a0 url: &#8220;{controller}\/{action}\/{id}&#8221;, \/\/\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&hellip; <a href=\"http:\/\/mairwa.com\/wordpress\/?p=216\">Read more &rarr;<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,10],"tags":[],"class_list":["post-216","post","type-post","status-publish","format-standard","hentry","category-c-vb","category-mvc","xfolkentry"],"_links":{"self":[{"href":"http:\/\/mairwa.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/216","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/mairwa.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/mairwa.com\/wordpress\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/mairwa.com\/wordpress\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/mairwa.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=216"}],"version-history":[{"count":0,"href":"http:\/\/mairwa.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/216\/revisions"}],"wp:attachment":[{"href":"http:\/\/mairwa.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=216"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/mairwa.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=216"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/mairwa.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=216"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}