开发者

Reading externally submitted form values into a webform

Is there any way to read form variables submitted from an external website to a .net form page? I need to submit a username/password combination from an outside website to a c#.net form page and have the values automatically entered into the corresponding login fields (to be self-submitted via javascript).

From what I learned, which is minimal开发者_StackOverflow社区, the framework only reads form variables if IsPostBack is true.


You can use Request.Form to access anything posted to that page. It doesn't have to be from an internal PostBack.

In your case, something like so would get you that value.

string user = Request.Form["Username"];


I would suggest that you have the HTML form submit the form values to a "Generic Handler" (.ashx) and store those values either A) in a session state, or B) pass them to the web form (.aspx) page via query parameters (probably A if you're talking passwords).

Technically any asp.net page or handler can access the Request.Form properties, which should contain all the form variables from a request. But it might get confused if the page also needs to handle it's own postback fields.

Also, if this is coming from another website (i.e. other domain) you can run into some problems with that. There are mechanisms in place that are meant to mitigate cross-site scripting attacks and other related cross-site attacks, so you might run into those.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜