.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
Easy Web
Imran Ghani
Post New Web Links

customErrors and PageMethods.

Posted By:      Posted Date: September 03, 2010    Points: 0   Category :ASP.Net
 
Hi, I am working on a project to add PageMethods to an existing webapplication.Everything works just fine, up until the point where I need to catch the exception that is thrown in the code behind and show it on the page.I did some research and discovered that you need to turn customErrors off in order to receive the error on the client side.The problem is that I can't do this, because I can't convert the whole webapplication to use PageMethods in one time. So if I turn the customErrors off and an error occurs on another page, the system won't redirect the user to the errorpage.So my question is: Is there a way to turn the customErrors off only for PageMethods (or Ajax requests)?


View Complete Post


More Related Resource Links

Corrupt URL bypasses ASP.NET 2.0 customErrors settings

  
A recent security scan of our website has identified a vulnerability which appears to be an issue with ASP.NET itself. By passing a seemingly innocuous yet malicious url the user will bypass the customError settings in the web.config and instead of getting a friendly error page, will see the "Server Error in '/' Application." error page. The underlying exception is: [HttpException (0x80004005): xxx is not a valid virtual path.] System.Web.VirtualPath.Create(String virtualPath, VirtualPathOptions options) +8855707 This is easily reproduced by creating a simple website project with a Default.aspx page, Error.aspx page and customErrors on pointing to the error.aspx page. Variations of the folllowing url will cause the undesired behavior. http://localhost/Default.aspx/%2fDefault.aspx%3ffree_text%3d This occurs on .NET 2.0, and 3.5, but run on .NET 4.0 it handles it as a 404 error. It appears that the bug has been fixed in 4.0, but I'm running 3.5. Has anyone seen this issue or have a solution? Just for curiousity it tried the same url on the following sites which exhibit the same bug. http://www.myspace.com/Default.aspx/%2fDefault.aspx%3ffree_text%3d https://www.discountasp.net/Default.aspx/%2fDefault.aspx%3ffree_text%3d  

web.config 404 customErrors

  
I am having an issue where if I change my url to .asp from .aspx i get a 404 error but it is not handled by my custom errors. If I change the url to def23947823h.aspx it is caught and redirects to correct page.  <customErrors mode="On" defaultRedirect="~/error/Error.aspx"> <error statusCode="404" redirect="~/error/File_Not_Found.aspx"/> <error statusCode="403" redirect="~/error/Authorization_Failed.aspx"/> </customErrors>  

pagemethods

  
HI ALL,loop is not working. loop continuesly run only one time calling this  OnComplete1why this ? and how to call 5 times.this is my code.var Valid = function () {            document.getElementById("<%=btnContactsMerge.ClientID%>").disabled = false;            PageMethods.sTotCount(OnComplete3, OnTimeOut3, OnError3);            return false;        }        var totCount = 0;        function OnComplete3(result) {            totCount = result;            for (var i = 0; i < totCount; i+=5) {                PageMethods.sMerge(OnComplete1, OnTimeOut1, OnError1);            }        }function OnComplete1(result) {            var lstAin = new Array();            lstAin = result;.............PageMethods.contactMerge(

Calling a Server side function from Javascript without using PageMethods

  
Good Day alli have used PageMethods to access the server side functions in javascript , but now my problem is that with pagemethods your controls will not go throught the full page lifecyle and these leads me to have "Object not set for an instance of an object" error. Now can someone come with a differnt approach without using pagemethods. What i want is to call a server side function , i dont want to pass any parameters to itthanks

when should i use pagemethods?

  

Hello. i  wonder this. when should i use pagemethods? i try to develop an online ticket selling site. i try making admin panel proceses with pagemethod. In Everywhere in site,i try to use pagemthods. Is this approach  true?


www.mysite.com/~/ gives 404 error despite customErrors

  

Greetings,

I have changed the web.config's on all my customer web sites to reflect the recommendations by MS. My error.html pages is triggered.  However I notice if I simply access the site as follows:  www.mysite.com/~/ it will throw a Server Error, 404 and reveals physical paths and server name.  How to protect against this?


asp.net valnuribility - change of customErrors section

  

hi !

I have implemented all insturictuons on scott guthrie's blog for the asp.net valnuribility.

here the link;

http://weblogs.asp.net/scottgu/archive/2010/09/18/important-asp-net-security-vulnerability.aspx

but for 404 error I am stille getting the below page;


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: /edew.aspx


I tired it with other application and it worked fine but in one app. it is

Getting error when using PageMethods in DD

  

I having error when using PageMethods to call my method in code behind.

i getting error: Microsoft JScript runtime error: 'PageMethods' is undefined

Anyone have some idea on it?

Please advice.

Thanks.

 

 


ASP.NET PageMethods - Back Button Causing 'Authentication Required' Prompt

  

Since last week I've had a really odd issue with PageMethods and the back button which i've never seen before.

Essentially, I have a 'home page' which on document.ready (using jQuery), loads some data through PageMethods, and then renders a list - from which you can click through to a details page about  the item. In general use, it works fine. However, using the back button after clicking through (ie: going back to the home page), it throws a PageMethods error. The browser's 'authentication required' prompt appears, and if you click cancel, the server returns a 404. The error returned by PageMethods on the client side is 'authentication failed'.

Just FYI, the application is using ASP.NET forms authentication. The weird thing is, this happens as soon as you click the link and click back. It's not like the authentication cookie has expired or anything, and if you click cancel when the prompt appears and refresh the page, it works fine. I just can't work out what is going on.

I've tried disabling caching on the page [as I thought it was something to down with some browsers' caches of the DOM), but the same thing happens.

One workaround i've had is to redirect the page to itself if the PageMethods error is 'authentication failed', which does work - but only when you cancel the authentic

Can not call two different pagemethods with two service methods??

  

I am using an AJAX dropdownlist control with two dropdownlist.  Instead of using a webservice to populate the data, I used the pagemethod to populate.  My problem is the second droplist won't populate.  I get a server error, 500 in the droplist.  The first droplist populates fine.

BUT here's the real kicker.  If I reverse the order of the public static function such that GetHelloList2 comes BEFORE GetHelloList1 in the code, then the GetHelloList2 works ...... it just seems like it is only firing one pagemethod event and allowign only one.


Here's my code:

ASPX

<asp:DropDownList ID="DropDownList1"
  runat="server" Width="285px" />
<br />Second droplist<asp:DropDownList ID="DropDownList2"
  runat="server" Width="285px" />
<br />


<cc1:CascadingDropDown ID="CascadingDropDown1"
  runat="server" Category="Hello3"
  TargetControlID="DropDownList1" ServiceMethod="GetHelloListPageMethod"
  LoadingText="Please wait" PromptText="Select a model">
</cc1:CascadingDropDown>

             <c

Pagemethods

  

My page expects a customer ID. Let's say that ID is an integer.

Here is how a URL to call such a page would look like: http://myserver/Customer.aspx?CustID=12
 

 

I using Pagemethods in my page, but it direct to http://myserver/Customer.aspx without concate my CustID.

 

Please advice.. Thanks


Why do I get default error page desipite setting customErrors mode="Off"?

  

I could never figure it out -  set  <customErrors mode="Off" /> in all web.config files that exist under Interpub/wwwroot, but still get default error page. Which web.config does SharePoint use?


ASP.NET PageMethods - Forms Authentication Cookie Not Always Sent

  

Since last week I've had a really odd issue with PageMethods, the forms authentication cookie, and the back button which i've never seen before.

Essentially, I have a 'home page' which on document.ready (using jQuery), loads some data through PageMethods, and then renders a list - from which you can click through to a details page about  the item. In general use, it works fine. However, using the back button after clicking through (ie: going back to the home page), it throws a PageMethods error. The browser's 'authentication required' prompt appears, and if you click cancel, the server returns a 401. The error returned by PageMethods on the client side is 'authentication failed'.

After inspecting the request in Fiddler, the forms authentication cookie isn't sent with the request, which would explain why it is happening. My fiddler entry for the request looks like this:

Cookies/Login
- ASP.NET_SessionId=XXXXXXXXXXXXXXXXX

The weird thing is, this happens as soon as you click the link and click back. It's not like the authentication cookie has expired or anything, and if you click cancel when the prompt appears and refresh the page, it works fine (and the cookie is sent). I just can't work out what is going on.

When it works, my Fiddler entry looks like this

Can't get past "turn customErrors mode=Off" page.

  
I'm getting the infamous runtime error page.  I do have customErrors mode set to Off.  What else can I try?

Runtime Error

Description: An application error occurred on the server. The current custom error settings for this application prevent the details of the application error from being viewed remotely (for security reasons). It could, however, be viewed by browsers running on the local server machine.

Details: To enable the details of this specific error message to be viewable on remote machines, please create a <customErrors> tag within a "web.config" configuration file located in the root directory of the current web application. This <customErrors> tag should then have its "mode" attribute set to "Off".

<!-- Web.Config Configuration File -->

<configuration>
<system.web>
<customErrors mode="Off"/>
</system.web>
</configuration>

Notes: The current error page you are seeing can be replaced by a custom error page by modifying the "defaultRedirect" attribute of the application's <cus

web.config customErrors tag

  

I'm having trouble getting the CustomErrors tag to work in WebMatrix. Here is my simple web.config:

<?xml version="1.0"?>
<configuration>
    <system.web>
        <compilation debug="false" targetFramework="4.0" />
        <customErrors mode="On">
            <error statusCode="404" redirect="404.cshtml"/>
        </customErrors>
    </system.web>
</configuration>


The problem is that when a 404 error happens, the site never redirects to my 404 error page. What else do I need to do to make this work?


WDP00002: missing section system.web/customErrors

  

 

 

Visual Studio 2005 Team Edition on W7 (32bit). New dev machine using an existing project pulled from VSS.

Categories: 
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend