Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

check logged in status without "Redirect"

Status
Not open for further replies.

crystalized

Programmer
Jul 10, 2000
390
0
0
CA
I have read several posts and different things where the &quot;Redirect&quot; method sounds like it is very unpopular.<br><br>At the same time each of the methods I have seen for checking if the user is logged in use a redirect method to send the user to a login page if they are not already logged in.&nbsp;&nbsp;Is there another way to handle this without the redirect.<br><br>I also have some firm guidelines for how I want the user to proceed through some of my forms so I have used a &quot;origin&quot; variable.&nbsp;&nbsp;Only when the user proceeds from the correct origin can they access the form.&nbsp;&nbsp;This method is also currently using a redirect when the user tries to access the form from a &quot;not legal&quot; origin.<br><br>I would appreciate input on reasons why the redirect is not a good choice, or why it is a good choice.&nbsp;&nbsp;I would also love to see any alternatives.<br><br>Thanks again for answers to a rookie's questions. <p>Crystal<br><a href=mailto:crystals@genesis.sk.ca>crystals@genesis.sk.ca</a><br><a href= > </a><br>--------------------------------------------------<br>
Experience is one thing you can't get for nothing.<br>
-Oscar Wilde<br>

 
You can use javascript code instead of asp coding response.redirect methoded.<br><br>suppose u are redirecting the user to &quot;login.asp&quot; page by checking a condition.<br>&lt;% If (some condition) Then <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Response.Redirect &quot;login.asp&quot;<br>&nbsp;&nbsp;&nbsp;else<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Response.Redirect &quot; to some other page&quot;<br>&nbsp;&nbsp;&nbsp;end if %&gt;<br><br>With the combination of asp and javascript we can avoide using response.redirect methoded<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&lt;% if (some condition ) then %&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;Script Language=&quot;JavaScript&quot;&gt;<br>&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;parent.document.location.href = &quot;login.asp&quot; ;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/script&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&lt;% else %&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;Script Language=&quot;JavaScript&quot;&gt;<br>&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;parent.document.location.href = &quot;some other pare&quot; ;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/script&gt;<br>&nbsp;&nbsp;&nbsp;<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&lt;%end if %&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;The main advantage using location.href of javascript is if any client side messages are not suppressed. if u used response.redirect methoded any messages in that page or not displayed to the user.<br>
 
Dear Crystal,<br><br>&gt; I would appreciate input on reasons why the redirect is not a good choice, or why <br>&gt; it is a good choice.&nbsp;&nbsp;<br><br>The single reason to avoid (client side)redirection whenever possible is that it requires a round trip back to the browser then back to the server to retrieve the targeted result page. While mckreddy's post is accurate, it still requires round tips.<br><br>&gt; I would also love to see any alternatives.<br><br>Well the best alternative is to migrate to IIS5 and use the new server side redirection method, Server.Transfer(). Please read the following article for a better description than I can provide:<br><A HREF=" TARGET="_new"> luck<br>-pete
 
Thanks <br><br>The article was helpful.&nbsp;&nbsp;I am using IIS5, so I think I will try the server.transfer() method out and see how it works.&nbsp;&nbsp;I'll let you know how it works.<br><br>Hey with all this good advice I have been getting maybe someday I will even be able to answer a question. <p>Crystal<br><a href=mailto:crystals@genesis.sk.ca>crystals@genesis.sk.ca</a><br><a href= > </a><br>--------------------------------------------------<br>
Experience is one thing you can't get for nothing.<br>
-Oscar Wilde<br>
 
Well I am guessing that I need to install some kind of service pack or something.&nbsp;&nbsp;I just get a error<br><br>Error Type:<br>Microsoft VBScript compilation (0x800A0408)<br>Invalid character<br>/NetworkForms/Forms/General/incCheckLogin.asp, line 18<br>&nbsp;&nbsp;&nbsp;&nbsp;Server.Transfer(&quot;../General/frmLogin.asp&quot; )<br><br>when I try to use the server.transfer method.<br>So I am thinking that for right now I will probably stick to the redirect with the hopes of changing over to the transfer method shortly.&nbsp;&nbsp;I have a couple other things I need to get going before this really becomes an issue anyway.<br><br> <p>Crystal<br><a href=mailto:crystals@genesis.sk.ca>crystals@genesis.sk.ca</a><br><a href= > </a><br>--------------------------------------------------<br>
Experience is one thing you can't get for nothing.<br>
-Oscar Wilde<br>
 
crystal:<br><br>Gone throgh pete's sugessated documentation. <br>Please check relative path where you are transfering the ASP page. Transfer and excute method are sensitive to it.<br><br>Anand <p>Anand Mishra<br><a href=mailto:anandm@entcomm.com>anandm@entcomm.com</a><br><a href= > </a><br>
 
Well I guess it shows to go ya that you really can not count on anything working the first time.<br><br>Earlier I removed the exact same piece of code that I just now put back in.&nbsp;&nbsp;Earlier I got some strange message about an invalid character.&nbsp;&nbsp;So I figured something must be wrong.&nbsp;&nbsp;So I went back to my old redirect.&nbsp;&nbsp;Now after the new message I thought I would try the relative path, even though I had checked it earlier and could see nothing wrong with it.&nbsp;&nbsp;So I put some other paths in there, one's I was fairly certain were not correct and I got a different error than the one before, so..........<br><br>Then I went back to the original path I had in there.<br><br>You will never guess what happened &gt;:)<br><br>Of course it worked, why would it not work.&nbsp;&nbsp;I would like to point out that between not working and working my InterDev crashed - you think that might have anything to do with it.<br>I love development when not all the bugs are your own mistakes ;-)<br><br>I guess this leads me to the question, Does anyone else have trouble with Interdev having &quot;memory&quot; errors that are reminiscent of Dr. Watson.<br> <p>Crystal<br><a href=mailto:crystals@genesis.sk.ca>crystals@genesis.sk.ca</a><br><a href= > </a><br>--------------------------------------------------<br>
Experience is one thing you can't get for nothing.<br>
-Oscar Wilde<br>
 
Dear Crystal,<br><br>&gt; Does anyone else have trouble with Interdev having &quot;memory&quot; errors that are reminiscent of Dr. Watson.<br><br>What OS are you running Interdev on, I have never run it on 95. It behaves well on NT 4 but can crash when the Server's FP extensions are not running correctly. On 98 you can get just about anything to crash if you run it long enough.<br><br>Now, a comment regarding relative paths. I recommend against using them, I almost always use virtual or absolute paths. This allows you to restructure your site with minimal pathing problems as 'search and replace' tools can be used to update many of the changes reqquired.<br><br>&quot;But, that's just my opinion... I could be wrong&quot;.<br>-pete
 
Actually because of budget concerns I am running Interdev right on the server itself.&nbsp;&nbsp;Not the way I would like to be doing things but.....<br><br>The server is running Windows 2000 server.<br><br>Could you tell me a bit more about virtual paths, I have read a bit about them but am not sure exactly where I read it. <p>Crystal<br><a href=mailto:crystals@genesis.sk.ca>crystals@genesis.sk.ca</a><br><a href= > </a><br>--------------------------------------------------<br>
Experience is one thing you can't get for nothing.<br>
-Oscar Wilde<br>
 
Dear Crystal,<br><br>Your Virtual directory in IIS is the root directory of your application, i.e., say your machine has this path<br><br>D:/inetput/ where IIS has set this up at installation time<br><br>Now suppose you create an ASP application at this location with these sub folders<br>D:/inetput/ then in your code the folder ' is the root folder of your application so to supply a virtual or absolute path to a jpeg file named logo.jpg it would look like this &quot;mytest/images/logo.jpg&quot;. Maybe you have a menu.asp file in your include folder to be SSIed into all your pages, the code would look like this:<br><br>&lt;!-- #include virtual=&quot;mytest/include/menu.asp&quot; --&gt;<br><br>So that paths are 'absolute' to the root folder of the Web site rather than 'relative' to the current folder which is not always as obvious as it might seem with things like SSI and SS transfer and execute.<br><br>Now if you create a new 'Web site' the folder that it is placed in becomes the 'root' folder for that site and all the resources within it.<br><br>Hope this helps<br>-pete
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top