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? |
Its not something simple like a reserved html symbol in the url parameter ?
I had a problem years ago where I was passing §ion=1 into a page and it was erroring as § 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 |
It's plausible, I suppose the offending parameter is &status=Y.
|
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 |
Thanks for the offer JJ. A screen shot of what? The source code of the receiving page?
|
yup and the error pwease :)
|
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. |
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 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 End Sub
Label4.Text = "Status = C" 'do stuff End If 'end If WPtransStatus = "C" 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. |
Looks ok. If you call the page by hand with the status parameter what error does it give. Could you paste that in here?
|
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? |
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 |
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> <!-- Web.Config Configuration File --> <configuration> <system.web> <customErrors mode="RemoteOnly" defaultRedirect="mycustompage.htm"/> </system.web> </configuration> |
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 09:46 AM. |
© 2024 MH Sub I, LLC dba Internet Brands