Mohi
Mohi

Reputation: 1808

Redirect to a Custom 404 Page When the URL ends with Dot

In my web.config file, I putted this rule to redirect to a custom 404 page and it works fine for URLs that really doesn't exists.

<system.webServer>
    <httpErrors existingResponse="Auto" errorMode="Custom">
        <remove statusCode="404" subStatusCode="-1"/>
        <error statusCode="404" path="/CustomErrors.aspx" responseMode="ExecuteURL"/>
    </httpErrors>
</system.webServer>

My problem is for URLs that ends with a Point(.) character. For Example

http://192.168.1.151/login.

Or

http://192.168.1.151/login....

That causes the following error:

Server Error in '/' Application.
The resource cannot be found.

404 error

StackOverFlow handled this problem fine: 404 page in stackoverflow

Any advice could be helpful.

Upvotes: 2

Views: 822

Answers (1)

Mohi
Mohi

Reputation: 1808

Adding this attribute in the httpRuntime section helped:

<configuration>
  <system.web>
    <httpRuntime ... relaxedUrlToFileSystemMapping="true" .../>
  </system.web>
</configuration>

Gets or sets a value that indicates whether the URL in an HTTP request is required to be a valid Windows file path.

More information about relaxedUrlToFileSystemMapping

Upvotes: 4

Related Questions