I am creating a web application using C#. I have a login page that is
used authenticate the user and redirect them to another web page called
Run.aspx that runs an executable that takes their username as a
parameter. Currently I am using Response.Redirect(Run.aspx) to take
the authenticated user to the page.
Session ["UserName"] = userName.Text;
System.Web.Security.FormsAuthentication.RedirectFromLoginPage(userName.Text,
false);
Response.Redirect("Run.aspx");
Now I need to take the authenticated user to the page by opening a new
window. I have read most of the post concerning this subject and tried
the suggestions, but I can't open a new window. I have tried
something like this:
string script = "<script language='javascript'>window.open('Run.aspx',
'_blank');</script>";
Page.RegisterStartupScript("script", script);
and others, but nothing seems to work. I would really appreciate any
help, thanks.
Jason Kester - 20 Oct 2005 01:51 GMT
uh, where are you putting that script? In run.aspx itself?
And you've got issuse with your FormsAuthentication code.
Specifically, this line...
Response.Redirect("Run.aspx");
...will never get called. RedirectFromLoginPage does it's own header
redirect, back to whatever page redirected to it in the first place.
So unless you came to the login screen by being kicked off of run.aspx,
you'll never end up back there.
If you want to force your users to see run.aspx (and run whatever
client-side scripts live there) immediately after login, lop off that
RedirectFromLoginPage line, and use SetAuthCookie instead.
Good luck!
Jason Kester
Expat Software Consulting Services
http://www.expatsoftware.com/
---
Get your own Travel Blog, with itinerary maps and photos!
http://www.blogabond.com/
akanihuu@yahoo.com - 20 Oct 2005 04:31 GMT
I put the script code in the login.aspx.cs to replace the
Response.Redirect().
> uh, where are you putting that script? In run.aspx itself?
>
[quoted text clipped - 21 lines]
> Get your own Travel Blog, with itinerary maps and photos!
> http://www.blogabond.com/
Jason Kester - 20 Oct 2005 06:45 GMT
Again, RedirectFromLoginPage will end processing. No lines after that
will run. That's why your code is not working. It never gets a
chance.
As I said, use SetAuthCookie instead, and you'll at least get a chance
to see what your code does.
Jason Kester
Expat Software Consulting Services
http://www.expatsoftware.com/
---
Get your own Travel Blog, with itinerary maps and photos!
http://www.blogabond.com/