HOW TO Handle request from non browser application with an ASP.NET application

Discussion in 'ASP.NET / ASP.NET Core' started by Julien, Mar 16, 2005.

Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.
  1. Dear all,
    How to make sure that my ASP.NET application accept requests from non browser ( e.g. a test http request from a perl script).

    Today my application is working fine with a web browser, but I receive an HTTP/1.1 500 Internal Server Error when I test http request from a perl script.

    Thank you
     
  2. Bruce

    Bruce DiscountASP.NET Staff

    Does your client record the complete error? 500 Internal server error is a generic error. When you get a 500 on the browser, you should see the error details.

    i also suggest you try put some error catching routine in your web application. There are many ways to do that but I suggest you consider using global error trapping with global.asax

    http://www.codeproject.com/aspnet/errorhandling.asp

    Bruce

    DiscountASP.NET
    www.DiscountASP.NET
     
  3. Hi Bruce,

    I will try to be more specific:

    1. My web site is working fine

    2. But,I am not able to reference my site with search engine

    3. To understand why I am not able to reference my site with search engine, I found some tools on the Internet that are acting as web search engine robot (like http://www.searchengineworld.com/cgi-bin/servercheck.cgi) in order to see what they see

    4. I found out that that what they see is the following:




    Server Response: http://www.rentalps.com/

    Status: HTTP/1.1 500 Internal Server Error

    Date: Thu, 17 Mar 2005 21:16:48 GMT

    Server: Microsoft-IIS/6.0

    MicrosoftOfficeWebServer: 5.0_Pub

    X-Powered-By: ASP.NET

    X-AspNet-Version: 1.1.4322

    Cache-Control: private

    Content-Type: text/html; charset=utf-8

    Content-Length: 3528

    5. Obviously this is why they can not reference me

    6. However my site is working fine [​IMG]

    7. Conclusion: I do not know what to do .... or where to look at

    It would be nice to see if other ASP.NET site hosted in the same server are having the same error. Then it would mean that IIS might be rejecting non browser request ...

    Thank you again for your kind help ... I am kind of lost

    Julien
     
  4. Bruce

    Bruce DiscountASP.NET Staff

    asp.net application itself do not care whether the request is coming from a browser or other client as long as it is wellformed.

    Something else is causing the error.

    Bruce

    DiscountASP.NET
    www.DiscountASP.NET
     
  5. Bruce

    Bruce DiscountASP.NET Staff

    i understand exactly what you mean.

    500 error is an application error (if the server rejected some request, the error code would be something else, like a 403)

    That's why i suggest you to put error trapping in the code. When the search engine hit your website, the error would happend and hopefully the error trapping would tell you what the real error is.

    Bruce

    DiscountASP.NET
    www.DiscountASP.NET
     
  6. Ok, I understand now.
    I'll implement the error handling and try to get the description of the error.

    Thank you for your help
    Julien
     
  7. I finally find the bug:

    Error was in the "Application_BeginRequest" of my global.asax where I am trying to get access the HttpContext of the user browser: "HttpContext.Current.Request.UserLanguages(0)" ... it generated an error with search bot !

    Julien
     
  8. Hi Bruce,


    I implemented the error catching routine in my web application (using global error trapping with global.asax). I test it and it's working fine.


    However, no errorare generated when I am trying to access my website with the tools that are acting as web search engine robot (like http://www.searchengineworld.com/cgi-bin/servercheck.cgi) ... even though they can not read the site [​IMG]


    I found another tool that simulate web seach engine robot (http://www.spider-simulator.com/) and if I run this one against my website (www.rentalps.com) I get the following info (but still no error catching):


    Server Error in '/' Application. Object reference not set to an instance of an object. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
    Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
    Source Error:
    An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
    Stack Trace:
    [NullReferenceException: Object reference not set to an instance of an object.] Global.Application_BeginRequest(Object sender, EventArgs e) System.Web.SyncEventExecutionStep.System.Web.HttpApplication+IExecutionStep.Execute() +60 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +87
    Version Information: Microsoft .NET Framework Version:1.1.4322.2032; ASP.NET Version:1.1.4322.2063


    Any idea?


    Thank you


    Julien
     
  9. Bruce

    Bruce DiscountASP.NET Staff

Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.

Share This Page