开发者

Unable to Authenticate client using self-created token (asp.net C#)

I have a windows application that contains a web browser control. This app create a HTTPWebRequest (with "Put" method) that post an authentication token into my asp.net server. The server would verify the authenticity of the token in the login.aspx and then redirect the user to the Default.aspx. Unfortunately, FormsAuthentication.RedirectFromLoginPage does not redirect to the Default.aspx. My guess is the HTTPWebrequest doesn't support the redirection back to the browser before it redirected to the Default.aspx. Any ideas how to solve this problem??

The other problem开发者_StackOverflow社区 is I need to use the web browser control in the apps to show the Default.aspx.Therefore, I need to write the Default.aspx to the Response.OutputStream and send it back to the windows app.

When the windows app receive the response, it will call the following code to show the Default.aspx:

webBrowser.DocumentStream = Response.GetResponseStream();

Really Appreciate your responses. Thanks


HttpWebRequest supports redirection - I guess the support exists for authentication purposes. See HttpWebRequest.AllowAutoRedirect property - by default, it's true so you should get back the default.aspx from your web request object. The HttpWebRequest object is a stand-alone component and does not have any integration with WebBrowser control so you will not see the redirected page into the browser control automatically. At the most, you can capture the response (using GetResponse method) then use the response to load the content into web browser control.

I will suggest that you use tool such as Fiddler to capture the HTTP request/response between your application and web server to understand the issue.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜