So I'm trying to use MiniProfiler (https://github.com/MiniProfiler/dotnet) for WebForms website. What I did is:
install package using nuget
add MiniProfiler initialization in Global.asax.cs (Begin_request and End_request events)
add <%= StackExchange.Profiling.MiniProfiler.RenderIncludes() %> statement
set at web.comfig
And still MiniProfiler doesn't work. Simple troubleshooting shows that (in Chrome dev tools) on that page I expect to see MiniProfiler, I see
http://localhost/mycoolsite/mini-profiler-resources/results 404.0 - Not Found
More info: I use .Net FW 4.5.1, IIS8 and Intergated Mode (app pool)
Any Ideas what may be useful for me?
I've (very!) recently blogged about this, specifically the process of getting MiniProfiler working in a hybrid WebForms/MVC application.
Based on the steps that you've outlined that you carried out, it looks like you're missing (as compared to what I've got):
<%= StackExchange.Profiling.ClientTimingHelper.InitScript %>
That said, even without that line I still see server side timings and the MiniProfiler UI so I suspect that your web.config entry was/is incorrect.
Check to make sure that you've put this in configuration > system.webServer > handlers within your web.config:
<add name="MiniProfiler" path="mini-profiler-resources/*" verb="*" type="System.Web.Routing.UrlRoutingModule" resourceType="Unspecified" preCondition="integratedMode" />
There are a couple of other things that you can check as well:
Does the page that you're viewing live in a sub-folder that has a web.config either in it, or in a folder between it and the one where you added the handlers entry which <clear />s handlers?
Do you have anything else present in your application that could be capturing the request for MiniProfiler resources and returning a 404?
Related
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 1 year ago.
Improve this question
I have a WebAPI install on a server of mine and I keep getting the following error when browsing it:
HTTP Error 500.19 - Internal Server Error
The requested page cannot be accessed because the related configuration data for the page is invalid.
I set this up using Dot Net 5.0 WebAPI and I have it installed in the latest version of IIS after publishing to a directory.
Here's what my web.config looks like:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<location path="." inheritInChildApplications="false">
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="dotnet" arguments=".\akmazio-api.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="inprocess" />
</system.webServer>
</location>
</configuration>
<!--ProjectGuid: 3b944703-a011-4408-9581-8c919ba4ed0e-->
Any thoughts on what might be causing this issue and how to resolve it?
Publish Core to IIS requires installation of .NET Core Hosting Bundle, for more information about it, you can refer to this link.
If you have installed the .NET Core host bundle according to the above steps, but this problem is still not resolved. I suggest you try to deploy a core template application, I suspect there may be a problem with your application.
In addition, you can also use FRT to troubleshoot this issue.
It looks like the .NET Core Hosting Bundle needed to be installed, the application needed to be modified so Swagger works correctly by commenting out the env.IsDevelopment() if statement in the Startup.cs Configure() function, the following needed to be added to Startup.cs Configure() function:
app.UseForwardedHeaders(new ForwardedHeadersOptions
{
ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto
});
the public settings needed to be set to
Target location: C:\publish\directory
Delete existing files: true
Configuration: Release
Target Framework: net5.0
Target Runtime: win-x64
Deployment Mode: Self-Contained
And IIS needs to be configured so that the Application Pool has No Managed Code and runs using Network Service.
And voila I go to http://localhost/swagger/index.html and everything is now working correctly!
I have googled for the past 3 hours and found nothing on what to do with respect to the windows azure problem:
You do not have permission to view this directory or page.
I did a git master push to azure and the deployment was successful. I also turned on the failed request tracing but nothing shows up but the above statement.
Any ideas on how to troubleshoot this?
I just tested that if you don't deploy your main node.js file as server.js you will get this error because the web.config is specifically looking for server.js as below:
<handlers>
<add name="iisnode" path="server.js" verb="*" modules="iisnode"/>
</handlers>
To further troubleshot this issue you can access the website over FTP as described here.
AvkashChauhan's answer did lead me in the right direction but I also had to add proper rewriting rules. Here is my complete web.config
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation batch="false" />
</system.web>
<system.webServer>
<handlers>
<add name="iisnode" path="server.js" verb="*" modules="iisnode" />
</handlers>
<rewrite>
<rules>
<rule name="myapp">
<match url="/*" />
<action type="Rewrite" url="server.js" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
I hit this error too. I am using MVC and the reason for the error was that on my layout page I had a call to an action that isn't accessible to anonymous users:
#Html.Action("GetMenu", "Users")
For information, I register a AuthorizeAttribute() global filter in Application_Start and my Login action is decorated with AllowAnonymous:
[HttpPost]
[AllowAnonymous]
[ValidateAntiForgeryToken]
public ActionResult Login(LoginModel model, string returnUrl)
{
My website did work previously on IIS7, but Azure is less forgiving. I fixed the problem by adding a check like this:
#if (User.Identity.IsAuthenticated)
{
#Html.Action("GetMenu", "Users")
}
The azure tools have changed a lot since this question.
I recommend people using the azure-cli. But funny enough I actually don't use it after I have used it once to create a site.
What I use now is just the ability to push (git) directly to a remote that is named azure, and the cli is setting that up for you.
But if you don't want to install the cli you can essentially just add the remote repo (your site) manually, like this:
git remote add azure https://<site-or-appservice-name>.scm.azurewebsites.net/<site-or-appservice-name>.git
As you would with every other git remote.
Not specific to node.js but updating in case it helps others facing this issue for a regular web application. This can also happen if the index.html file is not present or is not found because it is in a sub-directory
I just came across this issue and in my case it was the ipSecurity configuration that was causing the issue. Just hd to go and change the allowUnlisted to true.
<security>
<ipSecurity allowUnlisted="false">
</security>
Simple configuration, in the azure portal go to your
web app ->
All settings ->
application settings,
under default documents add the specific name of your document which you want to view, wait for it to update, then refresh your azure link.
I had the same error message after a git push from a local repository.
Solved it by opening the Azure dashboard:
Web app / App deployment / deployment source
and selecting local git repository as deployment source
You need to move your server.js file to your root app folder.
Lots of answers, but I didn't see one that addressed the "how do I debug this?" question, which wasn't obvious to me as someone who is new to Azure and hadn't yet used Kudu diagnostics.
To see the debugging info you're looking for, just navigate to
mywebsite.scm.azurewebsites.net
when you encounter the "You do not have permission to view this directory or page." error on your own
mywebsite.azurewebsites.net
page. This will get you to the Kudu console and give you easy access to everything currently in your logs.
See also the many answers to the closed-but-popular How to debug "You do not have permission to view this directory or page"? question.
Hey everyone and thanks for taking the time to help.
I am stuck on this problem. I have an asp.MVC application and my client want to use nopCommerce for the shopping cart. I made a test MVC application and got the sub-application working great on a simple demo. The nopCommerce virtual directory is registered as an application in IIS and it runs fine in the demo. However when I try integrating the steps into my application I get a run-time compilation error:
CS0246: The type or namespace name 'Combres' could not be found (are you missing a using directive or an assembly reference?)
Line 56: <add namespace="System.Web.WebPages" />
Line 57: <add namespace="System.Web.Helpers" />
Line 58: <add namespace="Combres" /> <-----Error Line
Line 59: </namespaces>
Line 60: </pages>
The sub-application (nopCommerce) does not use Combres so I thought it was an inheritance issue so I did the location trick in the parent Web.Config file:
<location path="." inheritInChildApplications="false">
<system.web>
...
</system.web>
</location>
This got rid of the compilation error, but now there is no compilation of the file, the .aspx files just download to my computer instead of being executed. The main MVC application still runs great, I only get this downloading issue when I try to run the nopCommerce application. I am completely stumped, I am kind-of an IIS noob and am having to learn quick.
K found the answer to this. My companies platform, we use ASP.net MVC, was turning all requests with file.* into download requests. So what I wrote was working great, it was doing what is was supposed to...I just didn't know.
I am tackling ASP.NET, MVC 3, web development, for the first time, all at the same time. Please bear with me, as I know this subject has been discussed heavily from different angles. I still have not found the answer to my specific question: Why doesn't my application find my Error.cshtml file when a 404 occurs, when it finds it just fine with other errors?
(Environment: Win 7 64bit, IIS7, SQL 2008 Express, VS2010, ASP.NET 4, MVC3, EF v4)
I have a controller, WorkerController.cs, that correctly reads and writes from the database. If I change the database name without updating my DbContext, it gives me an error. When I change web.config to always show custom errors, shows me the /Views/Shared/Error.cshtml file.
I do not have a FooController.cs file. If I go to /Foo, I get a 404 error, as expected. It tells me it cannot find the resource /Foo.
When I set customErrors mode="On" and make an http request to /Foo, I get a 404 error saying that /Error.cshtml cannot be found.
I am searching for and reading the posts that discuss the various methods of handling errors with designated controllers, but I really want to know what I'm missing. Why does it find /Error.cshtml for other errors, but not the 404 error?
Other than setting customErrors="On", have you defined a specific redirect for 404 errors?
If you have, say, an ErrorController setup your web.config, for instance, like:
<customErrors mode="On" defaultRedirect="/error/Problem">
<error statusCode="404" redirect="error/FileNotFound"/>
</customErrors>
Or of you'd prefer static html pages for your errors:
<customErrors mode="On" defaultRedirect="Problem.html">
<error statusCode="404" redirect="FileNotFound.html"/>
</customErrors>
You might want to take a look at this other question for some more information:
ASP.NET MVC HandleError.
For improved error handling in MVC, though, you could also take a look at ELMAH (Error Logging Modules and Handlers):
You can (should)! get ELMAH as a NuGet package; the installer will do most of the setup for you
Take a look at Scott Hanselman's "introductory" post
Check this question/ansers on how to use it with ASP.NET MVC: How to get ELMAH to work with ASP.NET MVC [HandleError] attribute?
I have cornered this error down to a redirect action call by DotNetOpenAuth(http://www.dotnetopenauth.net/)
Basically I have implemented the example here
http://www.dotnetopenauth.net/developers/code-snippets/programmatic-openid-relying-party/
In my application while running locally I hit this line
return request.RedirectingResponse.AsActionResult();
At this point it completes this action and then the azure dev fabric load balancer crashes.
Here is where it gets strange. If I debug line by line into the redirect action it will not crash.
Has anyone seen anything like this that can give me some direction on a fix?
#dthorpe points out that I should tell you all I have tested this by deploying to the production environment and this does seem to work.
We had same problem. There is no fix I currently know of and application still works fine, while deployed in the cloud.
Yet for the local testing purposes I merely introduced switch (it could be compile-time ifdef DEBUG or configuration switch). Whenever there is attempt to authenticate via the OpenID in local dev fabric, we immediately assume the identity is valid and authenticated by the DotNetOpenAuth. This worked for us and allowed to move the development forward.
I have a fix. It's a slight hack, but it does work and you don't have to fake anything.
Change this:
return request.RedirectingResponse.AsActionResult();
to this:
string location = request.RedirectingResponse.Headers["Location"];
return Redirect(location);
This gets around the issue and allows authentication to proceed. I'll allow someone brighter than myself to give a detailed explanation as to why this is the case.
Hope this helps!
If anyone's looking for a quick fix for this, one option is to turn off Azure diagnostics, if you happen to not be using it. This is added to the web.config when you create your project, just comment out the "add" element as shown and you're done.
<system.diagnostics>
<trace>
<listeners>
<!--<add type="Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener, Microsoft.WindowsAzure.Diagnostics, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" name="AzureDiagnostics">
<filter type="" />
</add>-->
</listeners>
</trace>
Of course this turns off diagnostics so only do it if you're not using diagnostics!