468,110 Members | 1,814 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,110 developers. It's quick & easy.

Response.Rediect question

My script is designed to only allow the downloading of a file if a
cookie exists to say that someone is logged into my companies site.

A colleague set up a test area the extension .EXE is associated with
the aspnet_isapi.dll. This means that if anyone tries to access a .EXE
file in this area, web.config is run and web.config contains the code:

<authentication mode="Forms">
<forms name="myCookie2" loginUrl="login.aspx" />

The upshot of all this is that no file can be downloaded without going
to login.aspx first, and it's aspx that determines if the cookie to
allow downloading exists.
Now, to my problem. In login.aspx I have a simple bit of code that
first checks to see if the cookie exists. If it does, then if checks to
specific key to see if "logged_in" is true. If that also is true then I
create a URL to the file, and want to redirect to it. This is where I'm
falling over:

============= CODE ===============
<%@ Page Language="C#" Debug="true" %>
<script runat="server">

void DoDownload(String sDownloadName) {
HttpCookie ComCookie = Request.Cookies["Communities"];

if (ComCookie == null) {
Response.Write("Trace 1");

} else {
if (Request.Cookies["Communities"]["LoggedIn"] == "True") {

String sRedirectURL = "/_protectedFiles/"+sDownloadName;


} else {
Response.Write("Trace 2");



String sFileName = Request.Form["filename"];
String bRequireLogin = Request.Form["login"];

if (bRequireLogin == "false") {
Response.Write("Go right to the file " + sFileName);
} else {
Response.Cookies["Communities"]["LoggedIn"] = "True";


============= /CODE ===============

In the script above, everything seems to work just fine until the
redirect to sRedirectURL. if I do a Response.Write(sRedirectURL) then I
see what I would expect, e.g. "/_protectedFiles/filename.exe", but if I
stick with the Response.Redirect then the browser address bar only
shows "/_protectedFiles/" and not the actual file name.

is anyting wrong with how I'm creating the sRedirectURL variable, or
with how I'm doing the redirect?

Many thanks for any help

Nov 19 '05 #1
1 1424
"Kevin Blount" <ke***@questionmark.com> wrote in
news:11*********************@f14g2000cwb.googlegro ups.com:
is anyting wrong with how I'm creating the sRedirectURL variable, or
with how I'm doing the redirect?

You might want to use a HTTPHandler instead to handle leeching:


Lucas Tam (RE********@rogers.com)
Please delete "REMOVE" from the e-mail address when replying.
Nov 19 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by Mark | last post: by
5 posts views Thread by Ivo | last post: by
4 posts views Thread by david | last post: by
1 post views Thread by Solo | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.