473,320 Members | 1,887 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Response.Rediect question

Background:
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" />
</authentication>

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");
//Response.Redirect("/communities/index.asp");

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

String sRedirectURL = "/_protectedFiles/"+sDownloadName;

Response.Redirect(sRedirectURL);

} else {
Response.Write("Trace 2");
//Response.Redirect("/communities/index.asp");

}
}
}
</script>

<html>
<body>

<%
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";
DoDownload(sFileName);
}
%>

</body>
</html>

============= /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 1606
"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:
http://www.uberasp.net/GetArticle.aspx?id=13

http://www.netomatix.com/development...eDownload.aspx

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

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: JC | last post by:
Hi, I have a simple question regarding the Response.Redirect method. Does the server stop processing the ASP code as soon as it encounters the Redirect command? Or does it ever continue to...
6
by: Mark | last post by:
Hi... I've come across some weird bug with Response.Cookies. Or maybe it will be called "by design" but for the life of me I can't figure out what purpose it would serve. If you're setting a...
5
by: Ivo | last post by:
Dear Newsgroup, many framed sites have an ancient script in all their pages: if(top==self) top.location=theframeset Some friendlier ones do this: if(top==self) document.write( '<a...
6
by: dotnettester | last post by:
Woud this work? ..... Response.end set objConn = nothing set objAnyObject = nothing ?
11
by: Russ | last post by:
My web app writes some binary data to a file at the client site via Response.Write and Response.BinaryWrite. This action is accomplished in response to a button click, with C# code behind as...
7
by: Shapiro | last post by:
I have a scenario where I log a resquest to a database table and update the request with a corresponding response including the response time. I am using an HttpModule to do this. My challenge...
4
by: david | last post by:
I has a question: I can use Response.WriteFile to display images such as .jpg. But I can not us it to display words doc file in EI by calling Response.WriteFile("testdoc/DownloadLarge.doc"). It...
4
by: Hexman | last post by:
Code below ---- I've asked a similar question on this forum earlier. This is a slightly different situation. Previous Question ---- I'm trying to save some specific web pages to disk as...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.