Open web page in new window

A

akanihuu

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.
 
J

Jason Kester

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/
 
J

Jason Kester

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/
 

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

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,599
Members
45,175
Latest member
Vinay Kumar_ Nevatia
Top