locked
RewritePath when a request was generated from method="POST" RRS feed

  • Question

  • User-274009987 posted

     I have an old ASP page "send.asp" page that normally would post to "Receive.asp":

    <form id="myForm" action="Receive.asp" method="POST" enctype="multipart/form-data">

    What would happen with file upload data when I do a  RewritePath in a httpModule to .Net page? Is the uploaded files still available? - Currently mine seems to get lost

    ( I use this concept to integrate legacy applications in our new .Net MasterPage UI framework and works fine, except currently for file upload pages.)

     

    Any help would be appreciated.

     

    Monday, July 9, 2007 9:37 AM

All replies

  • User1161433742 posted

    Hi,

    You mean, you have ASP and ASP.Net pages residing in the same virtual directory?

    Tuesday, July 10, 2007 9:17 AM
  • User1622957740 posted

    Uhm an ASP classic page is not ever going to hit your ASP.NET site is it?

    RewritePath is something that's internal to ASP.NET so you can easily use it route a request to another page and maintain the same HttpContext information including a file. But you can use it to route to another application (ie. out of the HttpContext) or an ASP page as you're trying to do.

    You can do what you want as long as both source Url and target URL are both going to the ASP.NET pipeline. IN your case that probably means making your receiving page an ASPX page.

    +++ Rick ---

    Tuesday, July 10, 2007 9:20 PM
  • User-274009987 posted
    I think it is me that don’t explain myself and probably don’t know the internals to well, but it works 99% -  A lot of what I do i got from your articles, i would not have been able to do that myself. <?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p>I add application wildcard mapping in IIS on my folder where ASP pages are. I also make that folder an application folder. This ensure that all requests (including *.htm / *.asp) are processed by the .Net Framework first. (This works ONLY on Win2003 server - not XP.)<o:p></o:p>This enable me to detect an ASP "myPage.asp" page request in httpModule, do RewritePath to same application folder, but to look like:<o:p></o:p>hostingpage.aspx?url={0}  where {0} would be "myPage.asp"<o:p></o:p>In "hostingpage" code behind I use my own assemblies that do httpWebRequests. (Get/Post etc) From here i do request for "myPage.asp?asp=true", and the "asp=true" part stops a second RewritePath, and .Net/IIS pass the processing trough to the "normal" ASP "processor" in IIS (i'm out of my leugue here to explain it in detail) <o:p></o:p>This works fine with our Enterprise ASP based intranet because we had enterprise header and footer included files before, where I’m able to add custom tags to make html parsing easier. (Again, the most work was on custom parsing and runtime javascript modification to handle js events as well as form submissions to the right locations. Also to replace submit buttons with buttons that fire JavaScript to do cross page post backs to the right location) It is important to note that the coding standards in our ASP apps was very strict before - so it was relative easy to code the JavaScript parsing against it what could have been. But still it was a difficult task. Attempt this only on relative "simple" legacy applications is my recommendation now :)<o:p></o:p>In short - I’m able to do "screen scrape" of html and add that into a aspx page with the right master pages and new UI framework for our company without modifying ASP apps. The possible extra load/slower response in IIS we will have to manage and convert out applications to .Net with time. Any comments on the IIS load would be much appreciated.<o:p></o:p>But then back to the problem that is outstanding:<o:p></o:p>Lets say my ASP page has an html file upload input control - when that control is "hosted" and i post the request after a file was selected, then that file content is not available it seems - I can only find the input ID with the physical file location as value. (I have to loop trough Request.Files to build correct httpRequest to the receiving page and my file upload is not there) My next step was to loop detect file upload inputs in the normal request.Form.Keys (Our file uploads have strict naming rules so it would be: <input type=file id=fileMyUploadFile.... etc so with the id naming prefix i would know what input was a file), and then maybe manual find the file content that was uploaded - I’m stuck here<o:p></o:p>Any comment would be much appreciated.<o:p></o:p>Also i were able to detect that the problem is not in the httpModule it seems and probably wrong forum, but...<o:p></o:p> Regards, Gert<o:p></o:p>

     

    Wednesday, July 11, 2007 3:53 AM
  • User-274009987 posted

    I think it is me that don’t explain myself and probably don’t know the internals to well, but it works 99% -  A lot of what I do i got from your articles, i would not have been able to do that myself. 

    I add application wildcard mapping in IIS on my folder where ASP pages are. I also make that folder an application folder. This ensure that all requests (including *.htm / *.asp) are processed by the .Net Framework first. (This works ONLY on Win2003 server - not XP.)

    This enable me to detect an ASP "myPage.asp" page request in httpModule, do RewritePath to same application folder, but to look like:hostingpage.aspx?url={0}  where {0} would be "myPage.asp"

    In "hostingpage" code behind I use my own assemblies that do httpWebRequests. (Get/Post etc) From here i do request for "myPage.asp?asp=true", and the "asp=true" part stops a second RewritePath, and .Net/IIS pass the processing trough to the "normal" ASP "processor" in IIS (i'm out of my leugue here to explain it in detail) 

    This works fine with our Enterprise ASP based intranet because we had enterprise header and footer included files before, where I’m able to add custom tags to make html parsing easier. (Again, the most work was on custom parsing and runtime javascript modification to handle js events as well as form submissions to the right locations. Also to replace submit buttons with buttons that fire JavaScript to do cross page post backs to the right location) It is important to note that the coding standards in our ASP apps was very strict before - so it was relative easy to code the JavaScript parsing against it what could have been. But still it was a difficult task. Attempt this only on relative "simple" legacy applications is my recommendation now :)

    In short - I’m able to do "screen scrape" of html and add that into a aspx page with the right master pages and new UI framework for our company without modifying ASP apps. The possible extra load/slower response in IIS we will have to manage and convert out applications to .Net with time. Any comments on the IIS load would be much appreciated.

    But then back to the problem that is outstanding:

    Lets say my ASP page has an html file upload input control - when that control is "hosted" and i post the request after a file was selected, then that file content is not available it seems - I can only find the input ID with the physical file location as value. (I have to loop trough Request.Files to build correct httpRequest to the receiving page and my file upload is not there) My next step was to loop detect file upload inputs in the normal request.Form.Keys (Our file uploads have strict naming rules so it would be: <input type=file id=fileMyUploadFile.... etc so with the id naming prefix i would know what input was a file), and then maybe manual find the file content that was uploaded - I’m stuck here

    Any comment would be much appreciated.

    Also i were able to detect that the problem is not in the httpModule it seems and probably wrong forum, but...

     Regards, Gert<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p>

     

    Wednesday, July 11, 2007 3:56 AM