Grabbing content w/ a WebRequest from an Whidbey Forms Based Auth

G

Guest

Hi all--

I'm retrieving contents from my site using the retrieving images from the
database method listed here:

http://www.aspfree.com/c/a/ASP.NET/Retrieving-Images-from-a-Database--C---Part-II/

Basically, the page just returns the image into the page (also within the
same site) that's calling it.

However, because the entire site is under my Forms based auth (using
Whidbey), every time I try and request it, either directly in the web page,
or through a WebRequest, the site responds requiring authentication. I've
tried to do any of the following:

Impersonate the user requesting the image (since you already had to auth in
order to get to the site)
<code>
UriBuilder newURB = new UriBuilder("http://localhost:" + portNum +
Image1.ImageUrl);
WebRequest webReq = HttpWebRequest.Create(newURB.Uri);
webReq.ImpersonationLevel =
System.Security.Principal.TokenImpersonationLevel.Impersonation;
WebResponse webResponse = webReq.GetResponse();
</code>

Create a user and pass combo and building a webrequest
<code>
UriBuilder newURB = new UriBuilder("http://localhost:" + portNum +
Image1.ImageUrl);
newURB.UserName = "me";
newURB.Password = "12345";
WebRequest webReq = HttpWebRequest.Create(newURB.Uri);
WebResponse webResponse = webReq.GetResponse();
</code>

Turning off authentication to that page and directory:
<code>
<location path="mydir/e/">
<system.web>
<authorization>
<allow users="?" />
<allow users="*" />
</authorization>
</system.web>
</location>
</code>

I've read up and see there's a way to do it by getting the view state, but
that means every request for this image takes two requests... there's got to
be a better way! Thanks in advance!
 

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,769
Messages
2,569,582
Members
45,070
Latest member
BiogenixGummies

Latest Threads

Top