MVC :: Custom Error Pages For Different Areas?
Feb 6, 2011
I have two areas: Frontend and Backend - I would like to have two different error pages - so I have two files NotFound in /Areas/Frontend/Views/Shared/NotFound and /Areas/Backend/Views/Shared/NotFound. I have added also to Web.config in area Frontend:
<customErrors mode="On" defaultRedirect="Error">
<error statusCode="403" redirect="NoAccess" />
<error statusCode="404" redirect="/Areas/Frontend/Views/Shared/NotFound" />
</customErrors>
and in area Backend in Web.config:
<customErrors mode="On" defaultRedirect="Error">
<error statusCode="403" redirect="NoAccess" />
<error statusCode="404" redirect="/Areas/Backend/Views/Shared/NotFound" />
</customErrors>
But when I come in bad website url - for example: http://localhost/Backend/blablabla I don't see my NotFound website but:
Server Error in '/' Application.
The resource cannot be found.
Description:
HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly.
Requested URL: /Backend/blablabla
View 3 Replies
Similar Messages:
Nov 30, 2010
I have developed a website using ASP.net. The pages use a master page with the background image set to the colour I require. All appears OK until I resize the window - then as I reduce the window size and or change the zoom level - white blank areas appear on the background to the right of the page and textboxes remain the background colour overlaying the white areas. This also happens when view in other browsers.
View 4 Replies
Mar 2, 2011
I currently have:
<uc:MyControl ...>
<Template>
</Template>
</uc:Mycontrol>
I would like
<uc:MyControl ...>
<FishBiscuit>
html
</FishBiscuit>
<FishBiscuit>
html
</FishBiscuit>
<FishBiscuit>
html
</FishBiscuit>
<FishBiscuit>
html
</FishBiscuit>
However I'm not sure if it's possible, or how to wire it up if it is.
View 2 Replies
Nov 5, 2010
I'm using the old 404-rewrite method on a certain site that is tied to IIS6 *. So if I enter [URL] it calls my error page like so [URL]
Except if I call the page with a fragment, like [URL] I get the same result as above. I can't find the fragment anywhere:
Request.Url
Request.Url.OriginalString
Request.UrlReferrer
Request.RawUrl
headers, server variables, etc
This has come up because I want to resolve paths created by AJAX to their server-side versions. Is there any way for me to retrieve the original path from my handler?
View 1 Replies
Jan 27, 2011
Can anyone send me proper configuration settings in web.config for ASP.NET 4.0. I am unable to redirect pages to desired url on page not found. It seems there are changes in properties as compared to previous framework.
View 2 Replies
Dec 1, 2010
i have developed a production site in godaddy server.Now i want to display a custom error page if there is any error occurs in the site.i have made following changes in the web.config file ,
<customErrors mode="On" defaultRedirect="/Areas/User/Views/Shared/Error">
<error statusCode="403" redirect="NoAccess.htm" />
<error statusCode="404" redirect="/Areas/User/Views/Shared/Error" />
</customErrors>
But now if error occurs the server will display his default error page for 404 page.Now i want to display my customised error page.Please tell me the entire steps to implement this in asp.net mvc 2.0.i,e is there any coding i have to write in then controllers or in the global.asax.
View 1 Replies
Oct 6, 2010
I'm working on a website with legacy Classic ASP pages (being converted to ASP.NET on an as needed basis) and new ASP.NET pages. Use of IIS 7 Integrated Pipeline has been very helpful with our configuration. For example, we were able to get forms authentication working auto-magically with the classic ASP pages simply by configuring the appropriate sections of the web.config file (i.e. no changes were required to the Classic ASP pages, for more info see this).
A colleague of mine believes that custom error pages, as specified in the web.config <customErrors> section, should also be auto-magically applied to the classic ASP pages, but for our website it only works for the ASP.NET pages. Nor have I been able to find any information describing the capability of applying custom error pages to Classic ASP with the IIS 7 integrated pipeline. Is it possible to apply custom error pages to Classic ASP pages per a web.config for an website running under IIS7 with integrated pipeline? If so, how?
View 1 Replies
Apr 9, 2010
I have Created a custom CheckboxList as [Code]....
but when i am passing this cutom control another page via parameter to newxt page i am not able get the selected checkbox
View 5 Replies
May 19, 2013
I have read your article from aspsnippets.com about custom paging it really work, but there are a problem that if there are more record in database (2000 to 5000) than number of page index will be goes in large number. like 1 to 200, any way which can divide it like 12345678910...2000.
View 1 Replies
Feb 20, 2011
I'm using MVC 2, I need to change the default name "Areas" to <MyOwnAreaName>.
Is't possible to change default name "Areas" to my own name?
View 1 Replies
Jan 3, 2011
Hope this is the correct forum for this question. I am using VWD 2010 an have a web project and get the following error upon execution:
Parser Error Message: Unknown server tag 'custom:AjaxValidator'.
My code is as follows in the .cs file:
[Code]....
[Code]....
View 1 Replies
Feb 7, 2011
I was wondering if someone could point me in the right direction:
How do I generate a custom error page with the error message and get it to mail me that error message?
Is there a good tutorial out there that someone could point me 2.
View 4 Replies
Aug 13, 2010
I have created a custom control from scratch and it works fine as in you can build the project that uses it and it works fine at runtime. Problem is when you go to design view the control shows an error in the place of where the control should be rendered.
Error: '<SomeValue>' Could not be set to '<SomeProperty>'
This shows up on all my custom set properties. These properties are created as basic as possible. I can give the properties values in Source view and run the app just fine. I can even add a Onclick event. If I don't set any custom properties the control will render fine in Design view. It's only when I set a value to a custom property.
Property Code Example:
[Code]....
I've even removed the Category and Description tags with no difference.
I don't know if what I said makes sens, but I hope it does.
View 3 Replies
May 13, 2010
I was referred here by MSDN forums hope this is the right place - I have a custom control (:WebControl) that renders web.sitemap in a specific way. While it runs error free and produces the expected result, at Design-Time it complains
[Code]....
and have tried the SiteMapDataProvider Tag with and without the SiteMapProvider
attribute.Does anybody have (a) any experience with this, or (b) any suggestions as to how to track down the problem?
View 3 Replies
May 7, 2015
I want put custom error page in my website so I wrote below code in web.config
<httpErrors errorMode="Custom">
<remove statusCode="404" subStatusCode="-1" />
<error statusCode="404" subStatusCode="-1" prefixLanguageFilePath="" path="error-404.aspx" responseMode="ExecuteURL" />
</httpErrors>
is it correct?
or I should put other code?
View 1 Replies
Mar 24, 2010
Here's my Application_OnError event sink in global.asax.vb:
Sub Application_OnError(ByVal sender As Object, ByVal e As EventArgs)
Dim innerMostException As Exception = getInnerMostException(Me.Context.Error)
If TypeOf innerMostException Is AccessDeniedException Then
Security.LogAccessDeniedOccurrence(DirectCast(innerMostException, AccessDeniedException))
Dim fourOhThree As Integer = DirectCast(HttpStatusCode.Forbidden, Integer)
Throw New HttpException(fourOhThree, innerMostException.Message, innerMostException)
End If
End Sub
You'll see that if we've got an innermost Exception of type AccessDeniedException we throw a new HTTPExcpetion with a status code of 403 AKA 'forbidden'
Here's the relevant web.config entry:
<customErrors defaultRedirect="~/Application/ServerError.aspx" mode="On">
<error statusCode="403" redirect="~/Secure/AccessDenied.aspx" />
</customErrors>
So what we're expecting is a redirect to the AccessDenied.aspx page. What we get is a redirect to the ServerError.aspx page.
We've also tried this:
Sub Application_OnError(ByVal sender As Object, ByVal e As EventArgs)
Dim innerMostException As Exception = getInnerMostException(Me.Context.Error)
If TypeOf innerMostException Is AccessDeniedException Then
Security.LogAccessDeniedOccurrence(DirectCast(innerMostException, AccessDeniedException))
Context.Response.StatusCode = DirectCast(HttpStatusCode.Forbidden, Integer)
End If
End Sub
Which unsuprisingly doesn't work either.
View 1 Replies
Jul 13, 2010
I am trying to add paging to my datagrid. This datagrid stores hierarchical data. So the top row has several children rows that need to go beneath it. When a new top row type is going to be added I want to make a new page. This way all related rows will be displayed on the same page. So, I think the tricky part might be making pages with varying sizes. I am not sure how to go about attacking this issue. All of the custom paging examples I have seen still have x amount of rows per page. Like I said my pages have to all be various sizes.
View 1 Replies
Aug 2, 2010
how one might go about implementing your own custom tags in JS pages served by ASP.NET?
Basically what I am looking to achieve is a way of creating "includes" for my Javascript files by adding some code such as.
//Include Src="MyJavascriptFileLocation.JS"
And then having the ASP.Net handler serve my javascript file but also dynamically append the referenced javascript file to the location where the include is written.
View 2 Replies
Jan 13, 2010
have a CustomValidator in a user control which validates text in TextBox ( TextBox is in user control ). I am using this user control in multiple pages. For some pages i need fire custom Validator and for some pages not.
View 2 Replies
Mar 21, 2011
I am trying to determine the number of pages in a custom paged control I have Built
there are 46 records and I am trying to get to the exact number of pages when there are 5, 10, 25 items per page etc...
at 5 items per page I should have 10 pages
and at 10 items per pages I should have 5 pages
but my code returns values that cannot use.
this is my code:
[Code]....
those are values I get.
When maxrowperpage is 5
pagecountConverted is = 9
pagecount is = 9
When maxrowperpage is 10
pagecountConverted is = 5
pagecount is = 5
how can I get a correct quotient?
View 1 Replies
Feb 2, 2010
For some reason the Custom Errors for 404 pages are not working on my production server, but they work fine on development. Instead of going to the custom 404.aspx page, it goes to the ugly IIS 404 page.
Here is my Custom Errors protion of my web.config:
[Code]....
I changed the defaultRedirect to also go to my 404.aspx page just to make sure I was catching everything, but still it does't work. I know I could change the IIS 404 error to also point to my 404.aspx page, but that will not work for me because I need to capture the "aspxerrorpath" in the querystring for .net 404 errors. The IIS method will not give me that.
I am just hoping it is a server configuration I missed somewhere, but everything on production looks the same as on development.
View 9 Replies
Mar 23, 2011
I have a custom master page that I use in WSS3.0 (SharePoint 2007) and I am using a HTML 'DOC TYPE' which I am declaring at the top of the master page. The site all works very well with my master page apart from some of SharePoint controls which are acting a little funny, namely the People Picker for a People and Group field.If I remove the DOC TYPE declaration then the People Picker and other controls work perfectly and behave as they should but it sends some of my customisations/layout all over.
Before I spend a lot of time reviewing fixing the issues I get to my design without having the DOC TYPE declared, does anyone know if there is a certain DOC TYPE that is compatible with WSS3.0 / SharePoint 2007 and all of its features (i.e. People Picker Fields)?
View 1 Replies
May 12, 2010
I've a requirement where i need to pass some objects across the pages. So i created a custom class with all the properties required and created a instance of it and assigned all the properties appropriately. I then put that object in the session and took it the other page. The problem is that even when i set the properties values to the class it is coming as null. I set a breakpoint in the getter-setter and saw that the value itself is coming as null.
public class GetDataSetForReports
{
private Table m_aspTable;
private int m_reportID;
private string m_accountKey;
private string m_siteKey;
private string m_imUserName;
/// <summary>
/// Asp Table containing the filters
/// </summary>
public Table aspTable
{
get
{
return m_aspTable;
}
set
{
m_aspTable = aspTable;
}
}
/// <summary>
/// Report ID
/// </summary>
public int reportID
{
get
{
return m_reportID;
}
set
{
m_reportID = reportID;
}
}
/// <summary>
/// All the accounts selected
/// </summary>
public string accountKey
{
get
{
return m_accountKey;
}
set
{
m_accountKey = accountKey;
}
}
/// <summary>
/// All the sites selected
/// </summary>
public string siteKey
{
get
{
return m_siteKey;
}
set
{
m_siteKey = siteKey;
}
}
/// <summary>
/// Current User Name
/// </summary>
public string imUserName
{
get
{
return m_imUserName;
}
set
{
m_imUserName = imUserName;
}
}
}
This is how i'm creating an instance in the page1 and trying to get it in the page2. Page1 Code
//Add the objects to the GetDataSetForReports Class
GetDataSetForReports oGetDSForReports = new GetDataSetForReports();
oGetDSForReports.aspTable = aspTable;
oGetDSForReports.reportID = iReportID;
oGetDSForReports.accountKey = AccountKey;
oGetDSForReports.siteKey = Sitekey;
oGetDSForReports.imUserName = this.imUserName.ToString();
But the values are not getting set at all. The values are not passing to the class (to the setter) at all. Am i making any OOP blunder?
View 1 Replies
Mar 7, 2011
I'm having a wicked time trying to redirect the different error scenarios to a custom error page. Basically, I have put some code in Application_Error in global.asax, and done the necessary web.config settings to use Custom Errors.
In global.asax on Application_Error, I stored the Server.GetLastError in Session. The reason I have to store it in Session is because (as far as I know) you lose the exception when using "ResponseRedirect". And the reason I have to use ResponseRedirect is because I am using an UpdatePanel with AJAX calls, and any exception during the AJAX call shows up as a JavaScript error, and doesn't get handled using the custom error page (see this post).
void Application_Error(object sender, EventArgs e){ ////must perform this check to avoid the "Session state is not available in this context" errors if (HttpContext.Current.Session != null) { Session["LastException"] = Server.GetLastError(); } else { // (I think this happens when there are compile-time errors) Server.Transfer("~/Oops.aspx"); }}void Session_Start(object sender, EventArgs e){ //must perform this check to avoid the "Session state is not available in this context" errors if (HttpContext.Current.Session != null) { //initialize the session (http://forums.asp.net/t/1405077.aspx) Session["LastException"] = ""; }}
View 3 Replies
Jul 2, 2012
I am trying to handle the unhandled exceptions in my project.I tried with this following code in my web.config filebut it is not at all redirecting to an error page which i have created instead of that it is throwing an exception in my code itselef. How to print the error description over therein my custom error page.
---------------------------------------------------------------------------------------------------
<sys.web>......<customErrors mode="On" defaultRedirect="~/Error.aspx"></customErrors>...</sys.web>
---------------------------------------------------------------------------------------------------
And even i tried in Global.asax page in Application_Error() method like below
Exception ex = Server.GetLastError();Response.Redirect("~/Error.aspx?errmsg="+ex.message);Server.ClearError();
And in my Error.aspx.cs page i have placed a label and i have written code like this
protected void Page_Load(object sender, EventArgs e) {
Label1.Text=Request["errmsg"];
}
But it is not getting redirected my error page and not displaying anything on it.
View 1 Replies