Notices
Computer & Technology Related Post here for help and discussion of computing and related technology. Internet, TVs, phones, consoles, computers, tablets and any other gadgets.

ASP.NET and parameters in URL (request.querystring)

Thread Tools
 
Search this Thread
 
Old 22 March 2004, 09:50 PM
  #1  
Fatman
Scooby Regular
Thread Starter
 
Fatman's Avatar
 
Join Date: Aug 2002
Posts: 2,390
Likes: 0
Received 0 Likes on 0 Posts
Question ASP.NET and parameters in URL (request.querystring)

Hi folks,

Is there some sort of data type restriction on what can be passed in the URL? e.g. I have a page that takes data thus... page.aspx?something=123&somethingelse=456&somethin gnew=A

...except every time the parameter 'somethingnew' is passed, it generates a server error. I can pass other parameters (with numical values) fine, but whenever I try to pass this thing with an alphabetical value it fails. Why? Is the request.querystring method only capable of retrieving numerical data?

Or, does this suggest I've done something silly elsewhere in that page of code?
Old 23 March 2004, 12:19 AM
  #2  
judgejules
Scooby Regular
 
judgejules's Avatar
 
Join Date: Nov 2000
Posts: 1,227
Likes: 0
Received 0 Likes on 0 Posts
Default

Its not something simple like a reserved html symbol in the url parameter ?

I had a problem years ago where I was passing &section=1 into a page and it was erroring as &sect is a special symbol

A URL has a certain lenght if that helps... could you post the error message up, or PM me the code/error ?

Jules
Old 23 March 2004, 10:15 AM
  #3  
Fatman
Scooby Regular
Thread Starter
 
Fatman's Avatar
 
Join Date: Aug 2002
Posts: 2,390
Likes: 0
Received 0 Likes on 0 Posts
Default

It's plausible, I suppose the offending parameter is &status=Y.
Old 23 March 2004, 12:07 PM
  #4  
judgejules
Scooby Regular
 
judgejules's Avatar
 
Join Date: Nov 2000
Posts: 1,227
Likes: 0
Received 0 Likes on 0 Posts
Default

Hmm, tried that here and it doesnt seem to throw a prob. Error might lie elsewhere. Post a screeny a blank out any info you dont want to make public if you want and I'll see what I can spot.

J
Old 23 March 2004, 12:16 PM
  #5  
Fatman
Scooby Regular
Thread Starter
 
Fatman's Avatar
 
Join Date: Aug 2002
Posts: 2,390
Likes: 0
Received 0 Likes on 0 Posts
Default

Thanks for the offer JJ. A screen shot of what? The source code of the receiving page?
Old 23 March 2004, 12:18 PM
  #6  
judgejules
Scooby Regular
 
judgejules's Avatar
 
Join Date: Nov 2000
Posts: 1,227
Likes: 0
Received 0 Likes on 0 Posts
Default

yup and the error pwease
Old 23 March 2004, 12:25 PM
  #7  
stevencotton
Scooby Regular
 
stevencotton's Avatar
 
Join Date: Jan 2001
Location: behind twin turbos
Posts: 2,710
Likes: 0
Received 1 Like on 1 Post
Default

Having entities in the query string has no relation to the problem (or shouldn't have, unless some implementation is severely broken); any extended characters should be URL-encoded in the query string. HTML entities have no bearing because a URL doesn't contain any HTML (although IE 4.01 had a crappy bug which would entity-ise certain query string combinations, shown in access logs).

Steve.
Old 23 March 2004, 01:20 PM
  #8  
Fatman
Scooby Regular
Thread Starter
 
Fatman's Avatar
 
Join Date: Aug 2002
Posts: 2,390
Likes: 0
Received 0 Likes on 0 Posts
Default

The payment provider I'm using is WorldPay. If a callback fails they are able to send a notification email. That's what tells me the callback string they attempted to use. Here's an extract of one such email...

WorldPay callback failure message...
Our systems have detected that your callback has failed.
This callback failure means we were unable to pass information
to your server about the following transaction:
Transaction ID: (transaction ID removed)
Cart ID: (cart ID data removed)
Installation ID: (installation ID removed)
Error reported: Callback to http://www.url.com/page.aspx?status=Y&transaction=(numerical data removed)&MC_UserID=(numerical data removed): NOT OK, recevied HTTP status: 500
Here's an edit copy of the sub which is being called.

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim userIDstring As String
Dim transaction As String
Dim WPtransStatus As String
'(other definitions removed)

transaction = Request.QueryString("transaction")
Label1.Text = transaction
userIDstring = Request.QueryString("MC_UserID")
Label2.Text = userIDstring
WPtransStatus = Request.QueryString("status")
Label3.Text = WPtransStatus

If WPtransStatus = "Y" Then 'Yes, WP transaction authorised
Label4.Text = "Status = Y"
'(code removed)
If (condition removed) Then
'(code removed)
Else
If (condition removed) Then
'do stuff
End If
End If
End If 'end If WPtransStatus = "Y"
If WPtransStatus = "C" Then 'No, WP transaction cancelled
Label4.Text = "Status = C"
'do stuff
End If 'end If WPtransStatus = "C"
End Sub
I know there's a lot removed, but it's all irrelevant stuff. You'll notice that I've used ASP label controls to 'debug' the values in the variables transaction, userIDstring and WPtransStatus. I've also used another label to 'debug' whether two other conditional loops are being executed.

If I run the page without the 'status' parameter (but with the other two) then the page runs ok. The two labels are populated correctly with their respective values. The other two (the status one and the conditional loop one) are blank.

Hopefully I've just done something silly with the 'status' parameter. Something which I've missed even after typing/editing this post...? Thanks for the help guys.
Old 23 March 2004, 02:49 PM
  #9  
judgejules
Scooby Regular
 
judgejules's Avatar
 
Join Date: Nov 2000
Posts: 1,227
Likes: 0
Received 0 Likes on 0 Posts
Default

Looks ok. If you call the page by hand with the status parameter what error does it give. Could you paste that in here?
Old 23 March 2004, 03:45 PM
  #10  
Fatman
Scooby Regular
Thread Starter
 
Fatman's Avatar
 
Join Date: Aug 2002
Posts: 2,390
Likes: 0
Received 0 Likes on 0 Posts
Default

I was afraid you might say that. I was hoping there was some error that was blindingly obvious to someone else, yet that I couldn't see.

Error messages are switched off on the server for security reasons. I presume that it would generate the same error as WorldPay reported, HTTP 500.

What next?
Old 23 March 2004, 05:29 PM
  #11  
judgejules
Scooby Regular
 
judgejules's Avatar
 
Join Date: Nov 2000
Posts: 1,227
Likes: 0
Received 0 Likes on 0 Posts
Default

Set it up on a dev environment to see where its going wrong when you call it, or if the site is live, enable debugging for a few minutes in the early morning so you can see?

I'm guessing you dont have "Show friendly HTTP error messages" turned on in IE when you browse the broken page?

Jules
Old 23 March 2004, 06:10 PM
  #12  
Fatman
Scooby Regular
Thread Starter
 
Fatman's Avatar
 
Join Date: Aug 2002
Posts: 2,390
Likes: 0
Received 0 Likes on 0 Posts
Default

Yes, the site is live. The webserver is configured to show the following message whenever an error is thrown.

Server Error in '/' Application.
--------------------------------------------------------------------------------
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 <customErrors> configuration tag to point to a custom error page URL.
<!-- Web.Config Configuration File -->
<configuration>
<system.web>
<customErrors mode="RemoteOnly" defaultRedirect="mycustompage.htm"/>
</system.web>
</configuration>
I reckon your idea of enabling 'real' error messages temporarily will be a good solution. Shame it will have to be done at some silly time of the day when (hopefully) nobody will be using the site!
Old 03 September 2011, 12:31 PM
  #13  
umesh09
Scooby Newbie
 
umesh09's Avatar
 
Join Date: Sep 2011
Location: India
Posts: 1
Likes: 0
Received 0 Likes on 0 Posts
Default use try catch to fetch error

use try catch and send mail in catch to you. with exception message.




All times are GMT +1. The time now is 01:58 AM.