Kristian
Kristian

Reputation: 756

Django URL Error in Azure web app

I have Django app deployed in Azure Web App.The app is working correctly in development using:

manage.py runserver

The problem comes when the app is deployed and I have to confirm my registration from email, the URL is something like that:

http://testApp.azurewebsites.net/activate/InRoY4Jua1BhYnYuYmci:1b4pyC:R2Gak--Jwgl0z5gqb0mF6a9OPfU/

I got this error:

The request could not be understood by the server due to malformed syntax.

So after removing ":" from the URL the request works(it gives error for invalid activation link)

How could I allow my azure app to use ":" in my urls?

Solution thanks to benjguin!

Ended up using:

<system.web>
    <httpRuntime requestValidationMode="2.0" requestPathInvalidCharacters="&lt;,&gt;,*,%,&amp;,\,?" />
    <compilation debug="true" targetFramework="4.0" />
  </system.web>

This way I only ignore colon(":") from the invalid characters.

Upvotes: 0

Views: 240

Answers (1)

benjguin
benjguin

Reputation: 1516

WARNING: the default configuration filters potentially dangerous URLs. The following will disable this protection. Do that knowingly.

You could replace this portion of the web.Config

<system.web>
    <compilation debug="true" targetFramework="4.0" />
</system.web>

by this one

<system.web>
    <httpRuntime requestValidationMode="2.0" requestPathInvalidCharacters="" />
    <compilation debug="true" targetFramework="4.0" />
</system.web>

Explanations are available here: https://msdn.microsoft.com/en-us/library/e1f13641(v=vs.100).aspx

You can edit the web.Config file from testApp.scm.azurewebsites.net (same credentials as for portal.azure.com), Debug Console, CMD, then cd site\wwwroot. Scroll down to web.Config, you'll find a logo with a pen on the left that will open a text editor in the browser.

Screen shot of Kudu (scm) environment

Upvotes: 1

Related Questions