5

This is a strange error we're seeing sporadically on our website.

The strange thing about this error is it's being thrown in our URL rewritting IHttpModule. The line in question is:

var host = context.Request.Url.Host;

If I record context.Request.Url when this exception is thrown, it is an empty string.

This rewriting method is only called via our global.asax file:

void Context_AuthorizeRequest(object sender, EventArgs e)
     => URLRewriting.Process();

What might cause Request.Url.Host to be empty?

As a side note, we're seeing a lot of other errors being caught on the site that suggest someone is scanning our website with automated tools to discover weaknesses and exploits. I have a feeling this might somehow be related, although I'm unusure as to why Request.Url.Host would ever be empty.

Second side note, the users IP making this last request is a University network (not unusual for our website).

Tom Gullen
  • 61,249
  • 84
  • 283
  • 456

2 Answers2

0

I would focus on the fact that the context.Request.Url is empty.

Do you have any other IHttpModules that does something with the HttpContext earlier in the pipeline?

Is it possible that there is a relative HTTP request, as described here?

Do you know anything more about the request when the host and URL are empty?

Grzegorz Smulko
  • 2,525
  • 1
  • 29
  • 42
  • We only have one `IHttpModule` in the entire solution (the rewriter). I'll try adding in some more logging. – Tom Gullen Sep 23 '19 at 09:26
0

Could it be an invalid URL that your rewrite module was unable to map? According to this, if the rewrite map does not have a rule to map a request, you will get an empty string by default.

If you have captured the original requests that have caused the error, you might be able to replicate it and step through your code to verify this theory.

TZU
  • 936
  • 7
  • 10