Been looking around but cannot find an answer. I wrote an asmx on VS2012 locally works good. Now deploying to the remote target site it is becoming an issue. On that site there are other asmx services and in their global web.config they have this section
...
<system.webServer>
...
<handlers>
...
<add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=123456789" />
...
</handlers>
...
</system.webServer>
I placed my asmx on a subfolder defining an Application on IIS8 and I'm trying to overwrite that global setting with my local web.config, tried different permutations on the local web.config with location to avoid inheritance but so far it always gives me the lovely
Server error in '/my_svc' Application
CS0246: The type or namespace name 'ForeignNS' could not be found
Is it possible to override it by only changing my local web.config? If so how? If at all possible? Target site admin will not allow to change global web.config unless it is absolutely necessary.
Related
I am using asp.net ChartImageHandler to generate charts in my .aspx pages, Everything was working great until we tested application on a web farm environment.
The problem is that for some requests, Chart returns 404 error and cannot find the image, This is the config that we use:
<appSettings>
<add key="ChartImageHandler" value="storage=file;timeout=20;dir=c:\TempImageFiles\;deleteAfterServicing=false;" />
</appSettings>
I guess that it is because the chart is stored in one server and not stored in the other server.
I have this section in my web.config file:
<remove name="ChartImageHandler" />
<add name="ChartImageHandler" preCondition="integratedMode" verb="GET,HEAD,POST" path="ChartImg.axd" type="System.Web.UI.DataVisualization.Charting.ChartHttpHandler, System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3986ad364e35" />
ChartImageHandler is present in the handler mapping of site created in IIS.
As said in documentation page in here, What I understand is that for web farm environment, we should set the storage to file and the other two options are not applicable to web farm environment.
the dir path should be a network path and I tried this network path but it didn't work either ! here what the config look like with the network directory:
And also the network address \\serverIp\TempImageFiles is accessible from windows explorer.
Any suggestion for making this work is much appreciated !
Edit: We changed the affinity of load balancer and everything worked fine.
Good morning all,
I am attempting to implement my custom membership and role providers in my web application that I have implemented under the Default Web Site in my instance of IIS 7. My web application is running under a .NET 4 application pool.
However, after setting up the corresponding web.config, I get the following error:
Parser Error Message: Default Role Provider could not be found.
I have included the following block of code in the system.web section of the corresponding web application's web.config:
<membership defaultProvider="CustomMembershipProvider" userIsOnlineTimeWindow="20">
<providers>
<clear/>
<add name="CustomMembershipProvider" type="CustomProviders.CustomMembershipProvider,
CustomProviders, Version=3.0.0.0, Culture=neutral,
PublicKeyToken=3563615169617648" applicationName="/"/>
</providers>
</membership>
<roleManager enabled="true" defaultProvider="CustomRoleProvider">
<providers>
<clear/>
<add name="CustomRoleProvider" type="CustomProviders.CustomRoleProvider,
CustomProviders, Version=3.0.0.0, Culture=neutral,
PublicKeyToken=3563615169617648" applicationName="/"/>
</providers>
</roleManager>
Now I have seen all sorts of explanations as to how solve the error that I mentioned earlier. Most of them seem to suggest that I add tags to my provider blocks.
Some seem to suggest that I remove the role manager from the machine.config. And some still seem to suggest not removing or adding anything. This last approach does not seem to account that my web application is being run from IIS and not a local machine.
In the end, I have have tried these approaches to little avail. Can someone please explain to me how I can get passed this error? Thanks in advance!
I got this error when using the default MVC 4 web application.
I had to add the following to web.config and the error went away.
Under <system.webServer>
add
<modules>
<remove name="RoleManager"/>
</modules>
Two things:
enabled="false" should probably be enabled="true"
And I'm not convinced the applicationName="/" is helpful, but it may not be hurting, either.
I got this error message when adding an application in IIS 8 to our existing web site (Right-click on the website in IIS, select "Add Application"). The application's web.config only had the default tag, which was removing the default provider that the web site's web.config defined.
I removed the RoleManager tags completely from the application's web.config, and then the website and application started working properly.
I installed the elmah.mvc nuget package and kept the default configuration of that sans setting up sending an email and plugging it into a SQL database.
On my local machine when I use the Visual Studio host, I can open my app and access /elmah fine to see a report of the errors. However, when I try and access /elmah on production, I get two errors, first I get a 403 access is denied server error. Then in my email (from elmah) I get:
System.Web.HttpException: Server cannot set status after HTTP headers have been sent.
Anyone know what is going on here and how to fix? Thanks.
I tried the following so far as suggested by the answers below:
In <system.webServer>
<handlers>
<add name="elmah" verb="GET" path="elmah.axd" type="Elmah.ErrorLogPageFactory, Elmah"/>
</handlers>
And in <system.web>
<httpHandlers>
<add verb="POST,GET,HEAD" path="elmah.axd" type="Elmah.ErrorLogPageFactory, Elmah" />
</httpHandlers>
I tried setting the path to both elmah.axd and simply ~/elmah. All still give the same error, and still works locally, but not in production.
Edit: It actually also works when I remote into the server and access it via browser on there (not using localhost, but the actual site address). So what permission am I not having? Seems like it's at the server level.
You need to enable Elmah for remote access by adding the following configuration setting to the <elmah> section in your web.config file. The default setting for this value is false, which only allows localhost, hence why it is working on your local machine from within Visual Studio.
<elmah>
<security allowRemoteAccess="true"/>
</elmah>
I always seem to forget this myself and spend a few minutes scratching my head ;)
Make sure you HttpHandler is defined in the webServer section in your web.config file.
<system.webServer>
<httpHandlers>
<add name="elmah" verb="GET" path="elmah.axd" type="Elmah.ErrorLogPageFactory, Elmah"/>
</httpHandlers>
</system.webServer>
What kind of purpose do .axd files serve?
I know that it is used in the ASP.Net AJAX Toolkit and its controls. I'd like to know more about it.
I tried Googling for it, but could not find getting basic information.
from Google
An .axd file is a HTTP Handler file. There are two types of .axd files.
ScriptResource.axd
WebResource.axd
These are files which are generated at runtime whenever you use ScriptManager in your Web app. This is being generated only once when you deploy it on the server.
Simply put the ScriptResource.AXD contains all of the clientside javascript routines for Ajax. Just because you include a scriptmanager that loads a script file it will never appear as a ScriptResource.AXD - instead it will be merely passed as the .js file you send if you reference a external script file. If you embed it in code then it may merely appear as part of the html as a tag and code but depending if you code according to how the ToolKit handles it - may or may not appear as as a ScriptResource.axd. ScriptResource.axd is only introduced with AJAX and you will never see it elsewhere
And ofcourse it is necessary
Those are not files (they don't exist on disk) - they are just names under which some HTTP handlers are registered.
Take a look at the web.config in .NET Framework's directory (e.g. C:\Windows\Microsoft.NET\Framework\v4.0.30319\Config\web.config):
<configuration>
<system.web>
<httpHandlers>
<add path="eurl.axd" verb="*" type="System.Web.HttpNotFoundHandler" validate="True" />
<add path="trace.axd" verb="*" type="System.Web.Handlers.TraceHandler" validate="True" />
<add path="WebResource.axd" verb="GET" type="System.Web.Handlers.AssemblyResourceLoader" validate="True" />
<add verb="*" path="*_AppService.axd" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" validate="False" />
<add verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" validate="False"/>
<add path="*.axd" verb="*" type="System.Web.HttpNotFoundHandler" validate="True" />
</httpHandlers>
</system.web>
<configuration>
You can register your own handlers with a whatever.axd name in your application's web.config. While you can bind your handlers to whatever names you like, .axd has the upside of working on IIS6 out of the box by default (IIS6 passes requests for *.axd to the ASP.NET runtime by default). Using an arbitrary path for the handler, like Document.pdf (or really anything except ASP.NET-specific extensions), requires more configuration work. In IIS7 in integrated pipeline mode this is no longer a problem, as all requests are processed by the ASP.NET stack.
An AXD file is a file used by ASP.NET applications for handling embedded resource requests. It contains instructions for retrieving embedded resources, such as images, JavaScript (.JS) files, and.CSS files. AXD files are used for injecting resources into the client-side webpage and access them on the server in a standard way.
I am building a dummy WCF REST service just for purposes of learning how it works (preparing for real service build). I have the REST service working and responding with both JSON and POX formatting. However, I cannot get the routing solution to work in order to eliminate the ".svc" file. I am using VS 2010, WCF 4.0 and IIS 7.5 on Win Server 2008 R2.
Right now the URL works as: "/api/rest/rest.svc/json/myMethod" but I want to just have "/api/rest/json/myMethod". I have found numerous articles here on SO and elsewhere which claims to remove the ".svc" file. I believe I have it setup as instructed, but the project will not build because of an error in the Global.asax file.
It says to add the following to the Application_Start function:
RouteTable.Routes.Add(new ServiceRoute("", new WebServiceHostFactory(),
typeof(RestService)));
I also added the following to the web.config:
<modules runAllManagedModulesForAllRequests="true">
<add name="UrlRoutingModule"
type="System.Web.Routing.UrlRoutingModule,
System.Web.Routing, Version=4.0.0.0,
Culture=neutral,
PublicKeyToken=31BF3856AD364E35" />
</modules>
<handlers>
<add name="UrlRoutingHandler"
preCondition="integratedMode"
verb="*" path="UrlRouting.axd"
type="System.Web.HttpForbiddenHandler,
System.Web, Version=4.0.0.0, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a" />
</handlers>
I also added the aspNetCompatibility lines to the web.config and above the class in the svc.cs file.
Th issue is that I can't even get the project to build. When I add the RouteTable.Routes.Add line to the global.asax and build it, I get the following errors:
The type
'System.ServiceModel.Activation.ServiceHostFactory'
is defined in an assembly that is not
referenced. You must add a reference
to assembly
'System.ServiceModel.Activation,
Version=4.0.0.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35'.
The type or namespace name
'ServiceRoute' could not be found (are
you missing a using directive or an
assembly reference?)
Any ideas why this is failing?
make sure that "System.ServiceModel.Activation, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" is referenced in the project, if it is make sure to add this to the web.config file as well. – Joakim Mar 25 at 19:03