3

All, I was stuck with a problem when I deploy a web site. I found there is an element named rewrite in the web.config.

<rewrite>
        <rules>
            <!-- below rule will abort api request when the request to pattern "apis/v.*" is of "http" method-->
            <rule name="AbortApiHTTPRequest">
                <!-- Note:
                        the below pattern is assumed that all apis conain prefix "apis/v", e.g. apis/v3/aaauth
                        if there are some exceptions for the assumption, below pattern needs to be updated.
                -->
                <match url="^apis/v.*$" />
                <conditions>
                    <add input="{HTTPS}" pattern="off" ignoreCase="true" />
                </conditions>
                <action type="AbortRequest" />
            </rule>

            <!-- below rule will redirect all non-https requests except for above requests to https request.-->
            <rule name="RedirectToHTTPS" stopProcessing="true">
                <match url="^.*$" />
                <conditions>
                    <add input="{HTTPS}" pattern="off" ignoreCase="true" />
                </conditions>
                <action type="Redirect" url="https://{SERVER_NAME}/{R:0}" redirectType="SeeOther" />
            </rule>
        </rules>
    </rewrite>

When I remove the element everthing is ok, the website works well. Otherwise I got a error says.

HTTP Error 500.19 - Internal Server Error The requested page cannot be accessed because the related configuration data for the page is invalid.

After I did some research, I found this question talking about it. I am not sure if it is the cause of the problem. seems it is just a xml syntax validation of Visual studio. Does it really matter with the deployment of web site in IIS 7?

Anyway, I also followed the instructions of the post , But I failed to get it works .even I run the cmd as the administrator. the error says below.

Failed to open file Xml\Schemas\DotNetConfig.xsd. Make sure that the script is run in the elevated command prompt.

I wandered if I have the enough previlige to run cscript command ? thanks.

More

If I run the project in the Visual Studio with the Asp.net development server, It can work without any error. But If I published the project to the IIS in my computer. It doen't work.

Community
  • 1
  • 1
Joe.wang
  • 11,537
  • 25
  • 103
  • 180
  • If you visit the website locally (i.e. on the same machine as the IIS service) do you get extended error information? – ta.speot.is Aug 15 '13 at 06:57
  • Yes, I published it in the IIS of my computer, and acess it in my computer, The full error information could be showed in the page. – Joe.wang Aug 15 '13 at 07:05

1 Answers1

3

The rewrite directive is used by URLRewrite module for IIS.

If the module is not installed, you will get an error similar to the above. You can either install the module if you need URLRewriting - or - comment out the entire <rewrite> section.

Salman A
  • 262,204
  • 82
  • 430
  • 521
  • +1 How can I find out if the module is installed or not ? thanks. – Joe.wang Aug 15 '13 at 07:09
  • In IIS manager, locate and click the website in the left hand pane; in the middle pane, you should see "URL Rewrite" under "HTTP Features" section. It does not ship with IIS or installed by default. – Salman A Aug 15 '13 at 07:11
  • Other method is to open "Modules" under "Server Components" and see if `RewriteModule: %SYSTEMROOT%\system32\inetsrv\rewrite.dll` exists in that list. – Salman A Aug 15 '13 at 07:16
  • Yeah, It is not installed yet. But A question comes out of my mind, Isn't the Url rewriting implemented in the HttpModule or HttpHandler? thanks. – Joe.wang Aug 15 '13 at 07:19
  • Sorry, I have no idea. I have only used this module (on IIS7 and IIRF on IIS6) for URL rewriting. – Salman A Aug 15 '13 at 07:23