Handling Post Request

S

Samuel Shulman

I have to create a page that all it does it handle a 'POST' request with
some parameters

So I created a blank page and in the Load event I try to handle the
parameters passed but the page doesn't open it and returns some error

Any suggestions?

Samuel
 
M

Mark Fitzpatrick

What error does it return? It's really hard to know what is going on without
knowing the error.

To handle post items, you would access them through the Request.Form
collection. What you'll need to do though is always test to ensure that the
form collection item is not null before you access it. If it's null you'll
get an error. In C# it would look like this.

string myVariable = string.Empty;

if(Request.Form["myvariable"] != null)
{
myVariable = Request.Form["myvariable"].ToString();
}

Keep in mind that all items are strings that are passed in since they are
all text. If it's another type, such as integer, you'll have to convert it
yourself. An example of an integer is (of course, still check to see if the
form field is null first):

int myVariable = Convert.ToInt32(Request.Form["myvariable"].ToString());
 
S

Samuel Shulman

it was a security problem
thank you,
samuel

Mark Fitzpatrick said:
What error does it return? It's really hard to know what is going on
without knowing the error.

To handle post items, you would access them through the Request.Form
collection. What you'll need to do though is always test to ensure that
the form collection item is not null before you access it. If it's null
you'll get an error. In C# it would look like this.

string myVariable = string.Empty;

if(Request.Form["myvariable"] != null)
{
myVariable = Request.Form["myvariable"].ToString();
}

Keep in mind that all items are strings that are passed in since they are
all text. If it's another type, such as integer, you'll have to convert it
yourself. An example of an integer is (of course, still check to see if
the form field is null first):

int myVariable = Convert.ToInt32(Request.Form["myvariable"].ToString());


--
Hope this helps,
Mark Fitzpatrick
Former Microsoft FrontPage MVP 199?-2006

Samuel Shulman said:
I have to create a page that all it does it handle a 'POST' request with
some parameters

So I created a blank page and in the Load event I try to handle the
parameters passed but the page doesn't open it and returns some error

Any suggestions?

Samuel
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,151
Latest member
JaclynMarl
Top