A bit basic, but I have tried some of the methods to tackle the following error but could not get the right solution.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title></title>
</head>
<body>
<form method="post">
<input type="text" name="query1"></input>
<input type="text" name="query2"></input>
<input type="submit"></input>
</form>
</body>
</html>
Error on running :
HTTP Error 405.0 - Method Not Allowed
The page you are looking for cannot be displayed because an invalid method (HTTP verb) is being used.
In the mappings of IIS, I have added the POST method but that did not work!
Suggestions please!
The following code has solved the problem for me(it's for php on iis).
web.config:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<handlers accessPolicy="Read, Execute, Script">
<remove name="PHP55_via_FastCGI" />
<add name="PHP55_via_FastCGI" path="*.php" verb="*" modules="FastCgiModule" scriptProcessor="C:\Program Files (x86)\PHP\v5.5\php-cgi.exe" resourceType="Either" requireAccess="Script" />
<add name="HTML_via_FastCGI" path="*.html" verb="*" modules="FastCgiModule" scriptProcessor="C:\Program Files (x86)\PHP\v5.5\php-cgi.exe" resourceType="Either" requireAccess="Script" />
<add name="HTM_via_FastCGI" path="*.htm" verb="*" modules="FastCgiModule" scriptProcessor="C:\Program Files (x86)\PHP\v5.5\php-cgi.exe" resourceType="Either" requireAccess="Script" />
</handlers>
<security>
<requestFiltering>
<fileExtensions>
<add fileExtension=".php" allowed="true" />
</fileExtensions>
<verbs>
<add verb="POST" allowed="true" />
<add verb="GET" allowed="true" />
<add verb="HEAD" allowed="true" />
<add verb="DELETE" allowed="true" />
<add verb="PUT" allowed="true" />
</verbs>
</requestFiltering>
</security>
</system.webServer>
Without seeing more, this could be a variety of problems. With that in mind, here is a list of possible fixes for your issue:
Cause 1
This problem occurs because the client makes an HTTP request by using
an HTTP method that does not comply with the HTTP specifications.
To resolve this problem, see resolution 1.
Cause 2
This problem occurs because a client makes an HTTP request by sending
the POST method to a page that is configured to be handled by the
StaticFile handler. For example, a client sends the POST method to a
static HTML page. However, pages that are configured for the
StaticFile handler do not support the POST method.
To resolve this problem, see resolution 2.
Resolution 1
Make sure that the client sends a request that contains a valid HTTP
method. To do this, follow these steps:
Click Start, type Notepad in
the Start Search box, right-click Notepad, and then click Run as
administrator.
Note If you are prompted for an administrator password or for a
confirmation, type the password, or provide confirmation. On the File
menu, click Open. In the File name box, type
%windir%\system32\inetsrv\config\applicationhost.config, and then
click Open.
In the ApplicationHost.config file, locate the
tag.
Make sure that all the handlers use valid HTTP methods.
Save the ApplicationHost.config file.
Resolution 2
Send the POST request to a page that is configured to be handled by a
handler other than the StaticFile handler (for example, the ASPClassic
handler). Or, change the request that is being handled by the
StaticFile handler so that it is a GET request instead of a POST
request.
MSDN Source
In my opinion you have 2 errors:
1) If your file extension is *.html change it to for example *.asp, *.php and it will work.
2)The input tag doesn't have closing tag.
Related
appSetting parameters
I have a value within app settings that I would like to use in my master page file but I think I am using the wrong syntax. Please bear with me because I am very new to Umbraco
My Web.config code is
<appSettings>
<add key="myKey" value="7829e" />
</appSettings>
The code within my master page is
<umbraco:Macro runat="server" language="cshtml">
#AppSetting.myKey
</umbraco:Macro>
It's not Umbraco related at all, you should be able to do
ConfigurationManager.AppSettings["key"]
Just like you would in standard ASP.NET.
I'm using an angular directive to pull an html file from my IIS7 classic mode server (classic required due to SSO). To satisfy CORS I need read the ORGIN from the request and add a header to the response of the html file. That bit doesn't really matter. My problem is hooking in my code to actually do this for a static HTML file.
So with classic mode my handlers/module are defined in system.web, not system.webSever. Therefore I can't use the runAllManagedModulesForAllRequests="true" flag which isn't part of the schema for system.web.
In system.web I have:
<httpHandlers>
<!--<add path="*.html" verb="GET,HEAD" type="System.Web.StaticFileHandler" />-->
<add path="*.html" verb="GET,HEAD" type="My.Namespace.CrossOriginHandler, My.DLL.Name" />
<add path="*" verb="*" type="System.Web.HttpNotFoundHandler" />
</httpHandlers>
<httpModules>
<add name="CrossOriginModule" type="My.Namespace.CrossOriginModule, My.Dll.name" />
</httpModules>
This executes fine for a MVC pages or webapi calls. It does not execute for my static HTML file.
I'm starting to fear I'm going to need to write a custom ISAPI filter. Is there any other way to hook in my code? A configuration I'm missing or hook inbetween ISAPI filter and HttpModule?
There are a couple of options you have and definitely you should not need to write an ISAPI for that.
One option if you can set it for everyone blindly is to just use the httpProtocol section to add the header:
<system.webServer>
<httpProtocol>
<customHeaders>
<add name="Access-Control-Allow-Origin" value="*" />
</customHeaders>
</httpProtocol>
</system.webServer>
however, a much better option is to use URL Rewrite to set the headers and still have all the control to check for origins, and rewrite them appropriately.
I wrote a quick article on how to do that here:
http://www.carlosag.net/articles/enable-cors-access-control-allow-origin.cshtml
At a high level it means adding a URL Rewrite inbound rule to capture the Origin header and set it in a server variable. Then you can use that server variable later in an outbound rule to set it in a header. Optionally I used a Rewrite Map to condition the origins that you wanted to allow that.
<outboundRules>
<rule name="Set-Access-Control-Allow-Origin for known origins">
<match serverVariable="RESPONSE_Access-Control-Allow-Origin" pattern=".+" negate="true" />
<conditions>
<add input="{AllowedOrigins:{CAPTURED_ORIGIN}}" pattern=".+" />
</conditions>
<action type="Rewrite" value="{C:0}" />
</rule>
</outboundRules>
see full explanation here: http://www.carlosag.net/articles/enable-cors-access-control-allow-origin.cshtml
I've added a button to print a SSRS report to one of my CRM ribbons. The only issue is that every time it calls the URL the path is removed from the url parameters. For example the URL I have in the XML is:
<CommandDefinition Id="Company.Form.quote.MainTab.Actions.PrintQuote.Command">
<EnableRules />
<DisplayRules />
<Actions>
<Url Address="http://<Server>/ReportServer/Pages/ReportViewer.aspx?/Test/ReportName">
<CrmParameter Name="QuoteId" Value="FirstPrimaryItemId" />
<StringParameter Value="Render" Name="rs:Command" />
<StringParameter Name="rs:Format" Value="PDF" />
</Url>
</Actions>
</CommandDefinition>
And the URL it navigates to is:
http://<server>/ReportServer?QuoteId=%7bE6D8DC8B-6381-E411-80BC-00155D18D500%7d&rs%3aCommand=Render&rs%3aFormat=PDF
It seems that I need a name for the ItemPath, but ReportServer doesn't accept one I know of, is there a way around this?
Any help is appreciated.
Found a workaround,
I did the same thing, just instead of putting the URL in the CommandDefinition I used javascript to redirect.
Suppose I want to render javascript from an external file inline into my layout file for performance reasons.
If I use the following Razor code
<script>
#RenderPage("~/Content/my.js")
</script>
results in
Server Error in '/' Application.
The following file could not be
rendered because its extension ".js" might not be supported:
"~/Content/my.js".
If I merely rename my javascript file to my.js.cshtml
<script>
#RenderPage("~/Content/my.js.cshtml")
</script>
The peasants rejoice.
The question:
Is there any simple way for me to prevent RenderPage from nagging such that I can tell it that the .js extension is fine?
With some feedback from #choudeshell one potential solution is:
<compilation debug="true" targetFramework="4.5">
<buildProviders>
<remove extension=".js"/>
<add extension=".js" type="System.Web.WebPages.Razor.RazorBuildProvider,
System.Web.WebPages.Razor"/>
</buildProviders>
</compilation>
What type of side effects would there be from removing whatever the default is for .js, any?
I have this variable defined in my web.config file :
<appSettings>
<add key ="version" value="123"/>
</appSettings>
and I am using it in my aspx pages' headers without problem:
<link rel="stylesheet" type="text/css" href="../css/style.css?<%= ConfigurationManager.AppSettings["version"] %>"/>
But this doesn't seem to work in a regular HTML page.
What is the correct way of using a web.config variable in straight HTML ?
Server code (for instance what you have in the <%%>) can't be executed on static pages.
You need to append this manually in your static pages, or convert them to dynamic pages (.aspx).
<%%> stands for:
<script runat="server"></script>
In a static page which is not routed through the ASP.NET engine, this will not do anything and will not get converted to server code.