Showing posts with label MVC. Show all posts
Showing posts with label MVC. Show all posts
0
protected void Application_BeginRequest(object sender, EventArgs e) { String fullOrigionalpath = Request.Url.ToString(); if (fullOrigionalpath.Contains("?p=")) { string website = "http://" + Request.Url.Authority; Response.Clear(); //Response.StatusCode = 301; Response.Status = "301 Moved Permanently"; //Response.Redirect(fullOrigionalpath.Replace("default.aspx?p=", "") + "/"); Response.AddHeader("Location", website + "/" + Request.QueryString["p"].ToString() + "/"); Response.End(); } }
0
Posted on 2:02 AM by Softminer and filed under
MVC
public static void InfoButton(this HtmlHelper helper, string id, string description) { var response = helper.ViewContext.HttpContext.Response; System.Web.Mvc.Html.RenderPartialExtensions.RenderPartial(helper, "_partial", new ViewDataDictionary { { "id", id }, { "descr", description } }); }
0
Sometime in ajax controller u wanna return back error message and Onfailure will be called only if status code is 500 and usually this error is handled by IIS, to skip this error do following:
Server.ClearError();
Response.StatusCode = 500;
Response.TrySkipIisCustomErrors = true;
+
Sometime in ajax controller u wanna return back error message and Onfailure will be called only if status code is 500 and usually this error is handled by IIS, to skip this error do following:
Server.ClearError();
Response.StatusCode = 500;
Response.TrySkipIisCustomErrors = true;
+
1
Definition from wikipedia
design pattern that prevents some duplicate form submissions, creating a more intuitive interface for user agents (users). PRG implements bookmarks and the refresh button in a predictable way that does not create duplicate form submissions.
Wikipedia
ASP.NET MVC - Using Post, Redirect, Get Pattern
ASP.NET MVC Tip #6 – Call RedirectToAction after Submitting a Form
PRG Pattern in the ASP.NET MVC Framework
Definition from wikipedia
design pattern that prevents some duplicate form submissions, creating a more intuitive interface for user agents (users). PRG implements bookmarks and the refresh button in a predictable way that does not create duplicate form submissions.
Wikipedia
ASP.NET MVC - Using Post, Redirect, Get Pattern
ASP.NET MVC Tip #6 – Call RedirectToAction after Submitting a Form
PRG Pattern in the ASP.NET MVC Framework
0
Problem with Resonse.Output in Razor
I have a helper class which writes directly in Response. I am using this helper class in my master page and it write in the position
where Helper class is called.
<% Html.MyHelper() %>
but in Razor
@{ Html.MyHelper() }
its writing the response on the begining of page.
A Razor view is rendered inside-out. Basically it writes content to temporary buffers which get written to the response stream when the top most layout page is reached.
private static void MyHelper(this HtmlHelper html)
{
HtmlTextWriter writer = new HtmlTextWriter(html.ViewContext.HttpContext.Response.Output);
}
to replace using
html.ViewContext.HttpContext.Response
with
html.ViewContext.write
Posted on 3:28 AM by Softminer and filed under
MVC
Problem with Resonse.Output in Razor
I have a helper class which writes directly in Response. I am using this helper class in my master page and it write in the position
where Helper class is called.
<% Html.MyHelper() %>
but in Razor
@{ Html.MyHelper() }
its writing the response on the begining of page.
A Razor view is rendered inside-out. Basically it writes content to temporary buffers which get written to the response stream when the top most layout page is reached.
private static void MyHelper(this HtmlHelper html)
{
HtmlTextWriter writer = new HtmlTextWriter(html.ViewContext.HttpContext.Response.Output);
}
to replace using
html.ViewContext.HttpContext.Response
with
html.ViewContext.write
0
Passing Data in an ASP.NET MVC Application
ASP.NET State Management Overview
How we do MVC – View models
Localization for ASP.NET MVC
How to encrypt Query string in MVC +,+, +
MVC4 Mobile features
MVC View Model Pattern
Architecture Guide: ASP.NET MVC Framework + N-tier + Entity Framework and Many More
Validating with Service Layer C#
Posted on 7:55 AM by Softminer and filed under
MVC,
Visual Studio
Passing Data in an ASP.NET MVC Application
ASP.NET State Management Overview
How we do MVC – View models
Localization for ASP.NET MVC
How to encrypt Query string in MVC +,+, +
MVC4 Mobile features
MVC View Model Pattern
Architecture Guide: ASP.NET MVC Framework + N-tier + Entity Framework and Many More
Validating with Service Layer C#
0
using Strongly Typed Html Helpers will map the model to the view and it will help to have compile time checking of the views.
in views instead of using
you can use
in controller:
use
moreover you dont need to use ValueProvider["UserName"].AttemptedValue to access Html value and you can use model directly.
and for adding attribute
using Strongly Typed Html Helpers will map the model to the view and it will help to have compile time checking of the views.
in views instead of using
<%=Html.TextBox("username", Model.UserName)%>
you can use
<%= Html.TextBoxFor( m => m.UserName)%>
in controller:
public ActionResult LogOn(string userName, string password)
use
public ActionResult LogOn(LoginViewModel loginviewModel)
moreover you dont need to use ValueProvider["UserName"].AttemptedValue to access Html value and you can use model directly.
and for adding attribute
<%= Html.TextBoxFor(model => model.UserName , new { @calss="SingleTextBox" }) %>
0
if you put this in .aspx code it will return back 0.0.0.0
you have to fill in either in controller or in Helper class:
here is how to fill it in helper class:
http://www.craftyfella.com/2010/01/adding-assemblyversion-to-aspnet-mvc.html
if you put this in .aspx code it will return back 0.0.0.0
- <%= System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString()%>
you have to fill in either in controller or in Helper class:
here is how to fill it in helper class:
http://www.craftyfella.com/2010/01/adding-assemblyversion-to-aspnet-mvc.html
0
Posted on 2:02 AM by Softminer and filed under
MVC
<img id="updating" src="/content/ajax-loader.gif" style="display: none;" alt="Updating ..." />
<br />
<%= Ajax.ActionLink("Get Time", "GetTime",
new AjaxOptions { UpdateTargetId = "time", LoadingElementId="updating" })%>
<br />
<%= Ajax.ActionLink("Get Time", "GetTime",
new AjaxOptions { UpdateTargetId = "time", LoadingElementId="updating" })%>
0
Usually by default the Views in MVC are Inherited from Inherits="System.Web.Mvc.ViewPage but you can Inherit it from specific Model.
first you have to define your model in your MVC Model folder. but when I add this to Page
Inherits="System.Web.Mvc.ViewPage<MyProject.Models.MyModel>" then I get the following Error :
Compiler Error Message: CS0426: The type name 'Models' does not exist in the type 'System.Web.UI.WebControls.Wizard'
Solution:
Posted on 12:43 AM by Softminer and filed under
MVC
Usually by default the Views in MVC are Inherited from Inherits="System.Web.Mvc.ViewPage but you can Inherit it from specific Model.
first you have to define your model in your MVC Model folder. but when I add this to Page
Inherits="System.Web.Mvc.ViewPage<MyProject.Models.MyModel>" then I get the following Error :
<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<MyModel>" %>
<%@ Import Namespace="MyProject.Models" %>
<%@ Import Namespace="MyProject.Models" %>