Web Connection
Expressionless URL match
Gravatar is a globally recognized avatar based on your email address. Expressionless URL match
  Mike McDonald
  All
  Jan 8, 2019 @ 02:20pm

Rick -

In the documentation for Using Expressionless URLs there is a line for the web.config file..

match url=".[^.]*$" />

The same match pattern was already in the web.config file (commented out) which was established when I created a new project through the WC Console utility. I installed the URLRewrite module, un-commented the web.config rule, set up the OnURLRewrite() process method, and everything worked correctly for a URL such as \virtual\method

However, it also matches for a URL with an extension, such as \virtual\style.css

An URL with an extension causes the OnURLRewrite() method to try to EVALUATE(THIS.methodname.wwd), because the IIS Rule has matched on the URL with the extension, instead of just URLs without an extension.

Changing the rule to match url="^.[^.]*$" /> seems to make it work as expected, but I'm not sure if there is some reason it should actually be using the default match pattern.

Mike McDonald

Gravatar is a globally recognized avatar based on your email address. re: Expressionless URL match
  Rick Strahl
  Mike McDonald
  Jan 8, 2019 @ 03:48pm

The RegEx matches any file url, but the <conditions> section below excludes any files or directories that exist on disk so style.css should not match.

This logic will fail on requests that are purely dynamic and don't have a matching file on disk though (ie. method calls only).

I have to take another look and see about a better regEx. It needs negating expression to ignore URLs that have a . in the path but it's actually a little more complicated than that since a the parent path could also have a . in it.

I've updated the docs with a little more info and a different RegEx expression that will exclude anything that has a . in it. The old one is commented out and still available. Neither is a perfect condition, but will handle slightly different use cases. The new one will fail on paths that have folders that have a . in them (which should be rare hopefully).

+++ Rick ---

Gravatar is a globally recognized avatar based on your email address. re: Expressionless URL match
  Mike McDonald
  Rick Strahl
  Jan 9, 2019 @ 10:42am

Rick -

The RegEx matches any file url, but the section below excludes any files or directories that exist on disk so style.css should not match.

Using style.css was a bad example on my part, because it would appear to be a file that does exist (and thus not get 'rewritten' by IIS due to the IsFile condition).

The real issue would be with a site which uses both expressionless URLs and URLs with an extension - /virtual/somemethod and /virtual/anothermethod.wwd - the latter fails because OnRewriteURL() then tries to EXPAND("THIS.anothermethod.wwd") which causes an error.

I have to take another look and see about a better regEx. It needs negating expression to ignore URLs that have a . in the path but it's actually a little more complicated than that since a the parent path could also have a . in it.

How about a RegEx that only checks for a . character within the string after the last / character - skipping the path? I don't know what that expression would be.

- Mike McDonald

Gravatar is a globally recognized avatar based on your email address. re: Expressionless URL match
  Rick Strahl
  Mike McDonald
  Jan 9, 2019 @ 12:24pm

Check the documentation - I updated it yesterday and it adds the check for just the ..

+++ Rick ---

© 1996-2024