Web Connection User Discussions
Extensionless Url Question
Gravatar is a globally recognized avatar based on your email address. Extensionless Url Question
  Michael B
  All
  Apr 24, 2020 @ 05:13am

Rick

I imagine like many of your users who manage a legacy application that they may be getting asked to get rid of the custom file extensions in their url's to make pages 'seo' friendlier... That said, I am working on exactly that, but for a headless version of our app (api calls and responses to our web stores).

I added your example code which works incredibly well, UNTIL a process method outside of 'this' is called. In other words, I have several process classes in use during a users visit (that all respond to the same extension), so if the function (ie 'page' or 'route') that is called is not in the same process prg, we get a routing error.

I decided to try and update the web.config and refer to a single sub folder so that i could direct calls to a specific function. That is working fine, but if a call that does NOT have 'api' as a folder in it, I still end up with the routing error.

Is my solution to work with the urlrewrite, or reorganize the functions in the app?

	<rule name="ExtensionLessUrls" patternSyntax="Wildcard" stopProcessing="true">		
		<match url="/api/(.*)" negate="true" />
		<conditions>
			<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
			<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
		</conditions>
		<action type="Rewrite" url="UrlRewriteHandler.wws" appendQueryString="true" />
	</rule>
Gravatar is a globally recognized avatar based on your email address. re: Extensionless Url Question
  Rick Strahl
  Michael B
  Apr 24, 2020 @ 01:37pm

You can always replace THIS with PROCESS (assuming THIS refers to Process class code). All the Web Connection objects are exposed as PRIVATE objects that are visible in the call stack below the Process method as part of initialization - inside of any Process methods or any methods that are called from there (ie. are in the call stack) you can refer to:

  • Process
  • Server
  • Request
  • Response
  • Session
  • Config

and get the appropriate process objects (ie. Process.oResponse, Process.oSession etc.)

+++ Rick ---

Gravatar is a globally recognized avatar based on your email address. re: Extensionless Url Question
  Michael B
  Rick Strahl
  Apr 25, 2020 @ 05:30am

Thank you for suggesting that, it surely works as you suspected, but in my app I did need to put the UrlRewriteHandler function at a higher level subclass of wwProcess to get it to work as you mention. My plan is to create a new app altogether for the api using latest version and I suspect that will make it work precisely as you mention.

© 1996-2020