Quantcast
Channel: West Wind Message Board Messages
Viewing all articles
Browse latest Browse all 10393

Re: Handling Default Document without that Default Document existing

$
0
0
Re: Handling Default Document without that Default Document existing
Web Connection
Re: Handling Default Document without that Default Document existing
12/02/2011
02:24:43 PM
3DH0UW1SQ Show this entire thread in new window
From:
Mike McDonald
To:
Attachments:
None
Brett -


Now, I understand the basics of why that subdirectory has to exist and why that file has to exist but my question is, can this be modified easily? If so we could more easily build an MVC type routing structure for Web Connect that would also be cleaner.


Our systems have the same general requirement that you are talking about here, and we use a special 404 configuration in IIS to make it happen.

Our corporate clients have consultants who want to be able to link to the company website in a way that the system will identify that particular consultant to whoever is visiting the site. For example a person may have a link such as domain.com/mylink or domain.com/johndoe (or whatever). There are no folders or files for these links, and so they will normally generate a 404 response straight from IIS.

However, we set the 'Custom Errors' in IIS so that the 404 'Type' is not set to 'Default' or to a particular 'File', but to 'URL'. You can set the URL to whatever you want, such as "/path/check404.ww". You would then set up a 'check404' method in your process class, which would parse the request and fire off to whatever other method or page is appropriate.

For IIS, the incoming request will look something like the following - this is what is returned from Request.QueryString()..

404;http://domain.com/johndoe

You just need to parse the link and figure out what needs to happen. In our case, it looks for a consultant record with 'johndoe' as their link - they can edit their own links when they are logged into the system, and they have to be unique. If the link is not found or otherwise invalid, the method responds with a standard 404 status.

The downside here is that every bad link will end up hitting your app (although that can be good, depending on your perspective - it certainly points out missing images and such when checking the request log). If you can limit the special 404 handler to a particular virtual that would be good. In our case, we have to apply the 404 to the root, and we set all subfolders to the standard 404 response handled by IIS.

Hope this helps..

- Mike McDonald
Software Design of Kentucky


We use some custom routing in our subclass of wwProcess so that we can have "friendly URLs" instead of parameterized URLs. For example, instead of this:

example.com/showitem.ww?itemnumber=123

we might have something like:

example.com/red-widgets/item-123.ww

Actually we scriptmap .htm to our Web Connect app and have a function called Index in our Class that handles .htm and have set our first Default Document to be Index.htm such that the function Index gets called when you go to just "example.com". Of course this same function gets called if you go to "example.com/this" or "example.com/that" PROVIDED you have a subdirectory (or virtual directory, w/e) named "this" and "that" off your main root AND have a file named Index.htm (the file can be a null file or a text version of War and Peace, doesn't matter).

Now, I understand the basics of why that subdirectory has to exist and why that file has to exist but my question is, can this be modified easily? If so we could more easily build an MVC type routing structure for Web Connect that would also be cleaner.

~Brett




Viewing all articles
Browse latest Browse all 10393

Trending Articles