Rohan Büchner
Rohan Büchner

Reputation: 5393

Send dynamic error/failed result message from server

I'm using jqgrid in a project. And need to know how to return/set error responses on the webserver to allow custom messages.

On my local instance i get the following result. Local

But on the deployed site on our webserver the messages get suppressed and replaced with the default message. Server

It's worth a mention that i return the error/failed result by setting the response status code to 500, and setting the description to my custom message. (is there perhaps a better way to do this)

Also ive added/modified the following config values.

<customErrors mode="On" />

<system.webServer>
       <httpErrors errorMode="Custom" >
         <remove statusCode="500" />
       </httpErrors>
</system.webServer>

Does anyone know what im doing wrong? Or how to get it working :P

Upvotes: 1

Views: 199

Answers (2)

Rohan B&#252;chner
Rohan B&#252;chner

Reputation: 5393

I found a solution. Before i updated my web.config to

<system.webServer>
       <httpErrors errorMode="Custom" >
         <remove statusCode="500" />
       </httpErrors>
</system.webServer>

It was set to (which explains why I experienced the issue in the first place, as I was accessing the site from a remote source)

<system.webServer>
       <httpErrors errorMode="DetailedLocalOnly" />
</system.webServer>

Changing it to the following

<system.webServer>
           <httpErrors errorMode="Detailed" />
</system.webServer>

and implementing Muhammad Mudassir suggestion, seemed to do the trick.

Upvotes: 0

Muhammad Mudassir
Muhammad Mudassir

Reputation: 124

Please try this, its better way for Custom Error Handling

Upvotes: 1

Related Questions