Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Request.PathInfo - how to get?
Boris
#1 Posted : Wednesday, February 20, 2008 6:51:49 AM(UTC)
Groups: Member
Joined: 2/20/2008(UTC)
Posts: 7

Hi!

My company is checking the possibility of running our web application locally, using Cassini Web Server.
The application is written in JScript.NET. The app mostly appears to work, except for two points:

- we make extensive use of XMLHTTP, and the server pages return empty response
(responseCode=200, responseText ="") seemingly at random. I have to do more testing before asking a concrete question,
but I can't help mentioning it )) . This is really strange; the same page may work one second and fail the next.

- we serve files using urls like: http://myapp/getdoc.aspx/document_id/file_name
where getdoc.aspx is implemented like this:
<%
var s = Request.PathInfo; // contains "document_id/file_name"
var documentId = ..; // split PathInfo to doc ID and file name
var fileName = ..;
// now we can find document's directory from ID
var filePath = findDocumentDir(documentId) + fileName;
Response.WriteFile(filePath)
%>
This is very convenient, since all document's resources (images, stylesheets etc. with relative URLs) are found automatically,
without using HTTP redirection or putting custom <BASE> tag in documents (yuck!). However, in Cassini such URLs produce HTTP 404 "not found". Is there a way around this?

thanks in advance,
Boris.
Ultidev Team
#2 Posted : Wednesday, February 20, 2008 10:02:14 AM(UTC)
Ultidev Team

Groups: Administration
Joined: 11/3/2005(UTC)
Posts: 2,253

Thanks: 28 times
Was thanked: 60 time(s) in 59 post(s)
Boris,

First problem is something of a mystery. As far as we know, Ajax uses XMLHTTP and we run MS Ajax Control Toolkit sample as a test application for Cassini, and never had any problem. If you have any additional info on this, please let us know.

Working around second problem would unfortunately require some changes on your part. You would have to use "http://myapp/getdoc.aspx?document_id/file_name" instead of "http://myapp/getdoc.aspx/document_id/file_name", and then Request.QueryString[0] instead of Request.PathInfo to the the "document_id/file_name" part.

Please let us know if this helps.

Best regards,
UltiDev Team.
Please donate at http://www.ultidev.com/products/Donate.aspx to help us improve our products.
Boris
#3 Posted : Wednesday, February 20, 2008 11:09:40 PM(UTC)
Groups: Member
Joined: 2/20/2008(UTC)
Posts: 7

Thanks for your reply. It's not a problem to change the code, of course. The problem is relative URLs - if I return a document with <img src="myimg.gif"> in it, the browser will try to fetch the image from http://myapp/myimg.gif and fail. I need to be able to trap this request and serve the image from document's own directory. Before we discovered the PathInfo trick, we used to set up redirection in IIS: requests for /myapp/doc/ are redirected to /myapp/getdoc.aspx?path=$P. But then, to make relative links work, we had to insert <base href="/myapp/doc/"> into documents on the fly. If Cassini supports redirection, we may go back to this method, but with PathInfo the solution is much more elegant.

best regards,
Boris.
Ultidev Team
#4 Posted : Thursday, February 21, 2008 5:25:16 AM(UTC)
Ultidev Team

Groups: Administration
Joined: 11/3/2005(UTC)
Posts: 2,253

Thanks: 28 times
Was thanked: 60 time(s) in 59 post(s)
Boris,

Unfortunately with Cassini the URL should end with the resource that Cassini can locate. Otherwise there will be 404 error. We can suggest one more possible workaround, but not sure if it's much different compared to the QueryString solution. You could try creating an HTTP handler class and register it in web.config. For example, you could register it as "DocGetter.axd". In this case, as long as your URL ends with "/DocGetter.axd", you should be able to have anything you want between the hostname segment and the /DocGetter.axd. For example, http://machinename/Base64EncodedPhysicalPath/DocGetter.axd. Then you could parse out the URL to extract actual path from it. Unfortunately this does not address the relative URL concern.

We are sorry if none of the workarounds we suggested so far help.. Please let us know anyway.

Best regards,
UltiDev Team.
Please donate at http://www.ultidev.com/products/Donate.aspx to help us improve our products.
Boris
#5 Posted : Saturday, February 23, 2008 10:13:13 PM(UTC)
Groups: Member
Joined: 2/20/2008(UTC)
Posts: 7

Thanks for the suggestion. As you said, it doesn't solve our main problem - that of relative links.
There are many URL rewriting modules for ASP.NET, is it possible to use anything like that in Cassini?
Or implement a custom 404 handler?

/Would be a shame if such a small detail prevented us from using Cassini.../

thanks in advance,
Boris.
Boris
#6 Posted : Sunday, February 24, 2008 3:46:15 AM(UTC)
Groups: Member
Joined: 2/20/2008(UTC)
Posts: 7

I downloaded the Cassini source from here: http://blogs.msdn.com/dm.../2006/03/09/548131.aspx
just to see how hard it would be to implement this feature. To my amazement, it worked right off the bat!
A simple test file, getdoc.aspx:
PathInfo=<%=Request.PathInfo%>
when accessed as /myapp/getdoc.aspx/mydir/myfile, produces: PathInfo=/mydir/myfile.

AFAIK, UltiDev Cassini is based on Cassini-the-Microsoft-sample-web-server; maybe this feature was added to the latter after the split.
Would it be hard to add to your product, having the source available?
best regards,
Boris.
Ultidev Team
#7 Posted : Monday, February 25, 2008 4:46:07 AM(UTC)
Ultidev Team

Groups: Administration
Joined: 11/3/2005(UTC)
Posts: 2,253

Thanks: 28 times
Was thanked: 60 time(s) in 59 post(s)
Boris, we'll definitely take a look at it. Request processor of our Cassini for ASP.NET 2.0 has the same code base as Dmitry's sample. It's surprising the behavior between the two is different.

Best regards,
UltiDev Team.
Please donate at http://www.ultidev.com/products/Donate.aspx to help us improve our products.
Boris
#8 Posted : Tuesday, February 26, 2008 7:13:07 AM(UTC)
Groups: Member
Joined: 2/20/2008(UTC)
Posts: 7

Thanks,
I'm waiting eagerly ! :)

best regards,
Boris.
Ultidev Team
#9 Posted : Tuesday, February 26, 2008 8:13:32 AM(UTC)
Ultidev Team

Groups: Administration
Joined: 11/3/2005(UTC)
Posts: 2,253

Thanks: 28 times
Was thanked: 60 time(s) in 59 post(s)
Boris,

We have logged the issue and will do our best to fix it in the next release.

Best regards,
UltiDev Team.
Please donate at http://www.ultidev.com/products/Donate.aspx to help us improve our products.
Boris
#10 Posted : Tuesday, February 26, 2008 10:34:51 PM(UTC)
Groups: Member
Joined: 2/20/2008(UTC)
Posts: 7

That's great. When is the next release expected?
Ultidev Team
#11 Posted : Thursday, February 28, 2008 6:35:00 AM(UTC)
Ultidev Team

Groups: Administration
Joined: 11/3/2005(UTC)
Posts: 2,253

Thanks: 28 times
Was thanked: 60 time(s) in 59 post(s)
Boris,

We are currently focusing our attention on delivering HttpVPN, so it will be probably a few months before the next release of another incarnation if Cassini, but we plan to do it this year.

Best regards,
UltiDev Team.
Please donate at http://www.ultidev.com/products/Donate.aspx to help us improve our products.
Boris
#12 Posted : Saturday, March 1, 2008 9:03:40 PM(UTC)
Groups: Member
Joined: 2/20/2008(UTC)
Posts: 7

OK, thanks.
Rss Feed  Atom Feed
Users browsing this topic
Guest (5)
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You can vote in polls in this forum.