Hi,
I'm writing an HttpModule in order to replace the parameters in the
aspx pages to look like subdirectories.
i.e. instead of having :
myexample.com/default.aspx?category=cat1&subcat=cat2
I want to have :
myexample.com/cat1/cat2/
While I was testing the functionality of HttpModule I was redirecting
from an ".aspx" file and it all was working fine.
Now that I switched to the real functionality, it just don't hit the
code.
I mean, the call to "myexample.com/cat1/cat2/" does not fire the
application request in my HttpModule.
Here is my code :
private void Application_BeginRequest(Object source,
EventArgs e)
{
HttpApplication application = (HttpApplication)source;
HttpContext context = application.Context;
string myPath = context.Request.
ServerVariables["PATH_INFO"];
string[] strs = ExtractParams(myPath);
string vendor="";
string category="";
if (strs.Length == 2)
{
vendor = strs[0];
category = strs[1];
context.RewritePath("~/default.aspx?
vendor="+vendor+"&category"+category);
}
}
Now, if I put a break in the first line I see that the code is not even
hit when I have something like "myexample.com/cat1/cat2/". It was
working if I have "myexample.com/cat1.aspx".
I guess I need to configure something, somewhere to call this code when
calling an URL with directories.
Thanks in advance. 9 1925
My guess is that the default in IIS isn't an aspx page (it's probably an
..html). Which means when people goto /cat1/cat2/ the request is actually
being passed to index.html which wouldn't get processed by ASP.net. you
need to change the default to default.aspx or something.
Karl
--
MY ASP.Net tutorials http://www.openmymind.net/ - New and Improved (yes, the popup is annoying) http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
<cr************@hotmail.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com... Hi,
I'm writing an HttpModule in order to replace the parameters in the aspx pages to look like subdirectories.
i.e. instead of having : myexample.com/default.aspx?category=cat1&subcat=cat2 I want to have : myexample.com/cat1/cat2/
While I was testing the functionality of HttpModule I was redirecting from an ".aspx" file and it all was working fine. Now that I switched to the real functionality, it just don't hit the code. I mean, the call to "myexample.com/cat1/cat2/" does not fire the application request in my HttpModule.
Here is my code :
private void Application_BeginRequest(Object source, EventArgs e) { HttpApplication application = (HttpApplication)source; HttpContext context = application.Context; string myPath = context.Request. ServerVariables["PATH_INFO"];
string[] strs = ExtractParams(myPath); string vendor=""; string category=""; if (strs.Length == 2) { vendor = strs[0]; category = strs[1]; context.RewritePath("~/default.aspx? vendor="+vendor+"&category"+category); }
}
Now, if I put a break in the first line I see that the code is not even hit when I have something like "myexample.com/cat1/cat2/". It was working if I have "myexample.com/cat1.aspx". I guess I need to configure something, somewhere to call this code when calling an URL with directories.
Thanks in advance.
My guess is that the default in IIS isn't an aspx page (it's probably an
..html). Which means when people goto /cat1/cat2/ the request is actually
being passed to index.html which wouldn't get processed by ASP.net. you
need to change the default to default.aspx or something.
Karl
--
MY ASP.Net tutorials http://www.openmymind.net/ - New and Improved (yes, the popup is annoying) http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
<cr************@hotmail.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com... Hi,
I'm writing an HttpModule in order to replace the parameters in the aspx pages to look like subdirectories.
i.e. instead of having : myexample.com/default.aspx?category=cat1&subcat=cat2 I want to have : myexample.com/cat1/cat2/
While I was testing the functionality of HttpModule I was redirecting from an ".aspx" file and it all was working fine. Now that I switched to the real functionality, it just don't hit the code. I mean, the call to "myexample.com/cat1/cat2/" does not fire the application request in my HttpModule.
Here is my code :
private void Application_BeginRequest(Object source, EventArgs e) { HttpApplication application = (HttpApplication)source; HttpContext context = application.Context; string myPath = context.Request. ServerVariables["PATH_INFO"];
string[] strs = ExtractParams(myPath); string vendor=""; string category=""; if (strs.Length == 2) { vendor = strs[0]; category = strs[1]; context.RewritePath("~/default.aspx? vendor="+vendor+"&category"+category); }
}
Now, if I put a break in the first line I see that the code is not even hit when I have something like "myexample.com/cat1/cat2/". It was working if I have "myexample.com/cat1.aspx". I guess I need to configure something, somewhere to call this code when calling an URL with directories.
Thanks in advance.
I had several default documents in my configuration, I removed them all
and left "default.aspx" alone, after restarting everything I still
seeing the same behavior : files with extensions fire the
"begin_request", directories does not.
Have you seen this working ? I mean, is it supposed to work ?
I've seen sites doing this, with PHP or Perl, but not with Asp.Net.
Also, all asp.net samples about this techniques are using files, with
extension to do the mapping, never seen a sample with "/directories/".
I had several default documents in my configuration, I removed them all
and left "default.aspx" alone, after restarting everything I still
seeing the same behavior : files with extensions fire the
"begin_request", directories does not.
Have you seen this working ? I mean, is it supposed to work ?
I've seen sites doing this, with PHP or Perl, but not with Asp.Net.
Also, all asp.net samples about this techniques are using files, with
extension to do the mapping, never seen a sample with "/directories/".
Hi Craig,
What exactly is your parser looking for?
I think what happens is that hte URL you're looking at will include
default.aspx in the Path Info, because that's what IIS translates it to...
Maybe that's causing you problems? IOW, you're going to get a different path
than just to path separators. You're going to get those plus Default.aspx
(ie. 3 parts).
+++ Rick ---
--
Rick Strahl
West Wind Technologies www.west-wind.com www.west-wind.com/weblog
<cr************@hotmail.com> wrote in message
news:11**********************@l41g2000cwc.googlegr oups.com... I had several default documents in my configuration, I removed them all and left "default.aspx" alone, after restarting everything I still seeing the same behavior : files with extensions fire the "begin_request", directories does not.
Have you seen this working ? I mean, is it supposed to work ? I've seen sites doing this, with PHP or Perl, but not with Asp.Net. Also, all asp.net samples about this techniques are using files, with extension to do the mapping, never seen a sample with "/directories/".
Hi Craig,
What exactly is your parser looking for?
I think what happens is that hte URL you're looking at will include
default.aspx in the Path Info, because that's what IIS translates it to...
Maybe that's causing you problems? IOW, you're going to get a different path
than just to path separators. You're going to get those plus Default.aspx
(ie. 3 parts).
+++ Rick ---
--
Rick Strahl
West Wind Technologies www.west-wind.com www.west-wind.com/weblog
<cr************@hotmail.com> wrote in message
news:11**********************@l41g2000cwc.googlegr oups.com... I had several default documents in my configuration, I removed them all and left "default.aspx" alone, after restarting everything I still seeing the same behavior : files with extensions fire the "begin_request", directories does not.
Have you seen this working ? I mean, is it supposed to work ? I've seen sites doing this, with PHP or Perl, but not with Asp.Net. Also, all asp.net samples about this techniques are using files, with extension to do the mapping, never seen a sample with "/directories/".
The parser is working fine. It does what I expect as long as I have
something like "/dir1/dir2.aspx". It does not work if I have
"/dir1/dir1/", because "Begin_request" is not being hit in this case.
After reading several dozens articles, I've got the conclusion that
what I'm trying to do requieres several tweaks : http://msdn.microsoft.com/library/de...lrewriting.asp
They told you'd have to create all the directories and put a default
document on it, if you want to allow people to look at them like
directories. They also says, that in order to avoid this, you'd need to
setup asp.net to handle all request, which would be a hard work.
So, I have to ask again, if somebody has seen this implementation, the
one where you can use "directories", like "/subdir1/subdir1/" in the
paths.
Hi Craig,
the problem is that you dont have an httphandler set to actually process the
request and render the page.
I have done something very similar which works well, from memory you need
to...
create an ihttphandlerfactory which in the GetHandler method calls
Web.UI.PageParser.GetCompiledPageInstance (very scarce documentation - I
don't think we are supposed to use it...)
in your IHttpModule you then need to set yourcontext.handler =
yourIHttpHandlerFactory.GetHandler(params....)
use this is to instatiate your template aspx page.
As I said this is from memory and there may have been a couple of other
steps... got to go into a meeting now but hopefully it will get you started
jd
"cr************@hotmail.com" wrote: The parser is working fine. It does what I expect as long as I have something like "/dir1/dir2.aspx". It does not work if I have "/dir1/dir1/", because "Begin_request" is not being hit in this case.
After reading several dozens articles, I've got the conclusion that what I'm trying to do requieres several tweaks : http://msdn.microsoft.com/library/de...lrewriting.asp
They told you'd have to create all the directories and put a default document on it, if you want to allow people to look at them like directories. They also says, that in order to avoid this, you'd need to setup asp.net to handle all request, which would be a hard work.
So, I have to ask again, if somebody has seen this implementation, the one where you can use "directories", like "/subdir1/subdir1/" in the paths.
followup: you also need to add a wildcard ISAPI mapping to the website in
IIS, make sure you remove the mapping from any sub folders wich serve images/
non processed docs or the aspnet engine will be used to serve them and it
will increase the load on the server.
HTH
jd
"london calling" wrote: Hi Craig,
the problem is that you dont have an httphandler set to actually process the request and render the page.
I have done something very similar which works well, from memory you need to...
create an ihttphandlerfactory which in the GetHandler method calls
Web.UI.PageParser.GetCompiledPageInstance (very scarce documentation - I don't think we are supposed to use it...)
in your IHttpModule you then need to set yourcontext.handler = yourIHttpHandlerFactory.GetHandler(params....) use this is to instatiate your template aspx page.
As I said this is from memory and there may have been a couple of other steps... got to go into a meeting now but hopefully it will get you started
jd
"cr************@hotmail.com" wrote:
The parser is working fine. It does what I expect as long as I have something like "/dir1/dir2.aspx". It does not work if I have "/dir1/dir1/", because "Begin_request" is not being hit in this case.
After reading several dozens articles, I've got the conclusion that what I'm trying to do requieres several tweaks : http://msdn.microsoft.com/library/de...lrewriting.asp
They told you'd have to create all the directories and put a default document on it, if you want to allow people to look at them like directories. They also says, that in order to avoid this, you'd need to setup asp.net to handle all request, which would be a hard work.
So, I have to ask again, if somebody has seen this implementation, the one where you can use "directories", like "/subdir1/subdir1/" in the paths.
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Bruce B |
last post by:
Hi group,
I'm experiencing some extreme weirdness over the last week with IIS related
to it's Mappings and how .NET is behaving. I can't explain the behavior as
it seems very random.
Our...
|
by: Dominik Amon |
last post by:
Hi,
I'm using HttpModules in my ASP.NET Application (Note, i'm not using
HttpHandlers!). Well, it works correctly for the hole application, but i
wan't to remove the httpModule for a special...
|
by: nail |
last post by:
Folks,
I develop a HttpModule and it works correct, but one problem is occurs.
After I register the httpmodule in the web.config, my pages (not testing
http://localhost/site but...
|
by: |
last post by:
I have earlier used an HttpModule that did URL rewrites on the BeginRequest
event.
Now I am trying to use the same module in a different application on a new
and upgraded machine (winxp sp2).
...
|
by: MWells |
last post by:
I'm having an issue getting my HttpHandlers and HttpModules to play together
nicely.
My HttpHandlers take special document types (defined by extension) and
process them specially. I might have...
|
by: craigkenisston |
last post by:
Hi,
I'm writing an HttpModule in order to replace the parameters in the
aspx pages to look like subdirectories.
i.e. instead of having :
myexample.com/default.aspx?category=cat1&subcat=cat2...
|
by: craigkenisston |
last post by:
I have an asp.net application.
This have a very special class that I use all over the site code.
I also have an HttpModule which has been working quite fine.
Now, due a strange requirement I need...
|
by: Manso |
last post by:
Hi,
We have an application that is installed in default web site (root web
site). The same application will be installed as virtual directories under
the root site e.g. <default web site>/app1...
|
by: =?Utf-8?B?bXVzb3NkZXY=?= |
last post by:
Hi guys
I'm working on a web app in VS2005 (.net 2.0.50727). All is working fine,
except when I add a HTTPModule to my web.config file, as follows...
<httpModules>
<add name="UrlRewrite"...
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| | |