Rest API Postman configuration section cannot be used at this path - c#

I have created a rest API in Visual Studio 2017. When I use Postman locally, it works great.
I published and tried to consume from another server and received the following error.
This configuration section cannot be used at this path. This happens when the section is locked at a parent level. Locking is either by default (overrideModeDefault=Deny), or set explicitly by a location tag with overrideMode=Deny; or the legacy allowOverride=false
and
Config File
C:\inetpub\wwwroot\API\web.config
I cannot see any issues with the web.config file.
Thank you in advance!

Related

Reading configuration from Web.config when Startup of WebAPI class is invoked from OWIN TestServer

We have an ASP.NET Web application that uses .net Framework 4.7.2 and I am supposed to develop integration tests for that app.
I have a problem with OWIN TestServer.
Our Api project uses ConfigurationManager to read settings from Web.config file, that is placed inside of that project. It successfully reads settings when i run the api project, but when i try to run my integration tests project, anytime when i try to read one of the values (example below), it returns null:
string test = ConfigurationManager.AppSettings["SomeSettingName"];
I did ctrl+f in Visual Studio to see if reading configuration from web.config file is explicitly configured somewhere, but i didn't find it. I tried to find in google how to to manually specify where that configuration is, but it doesn't help either:
ConfigurationManager.OpenExeConfiguration("C:\\Users\\myuser\\project\\full\\path\\OurApi\\Web.config");
string test = ConfigurationManager.AppSettings["SomeSettingName"];
It's still null. Does anyone have an idea how to fix this issue?

Web application - Parser error - Could not load type

I have a Web application that is my REST API. I have integrated an OWIN authentication server, to do so, i :
Added a Startup.cs file in /
Removed Global.asax from / (the file is useless because i have Startup.cs)
I tested my application locally and everything works fine. I published my web application on Azure and when the publication is finished and i'm redirected to the url, i get the following error:
What's strange is that the 'Source File' in which the error occurs is '/global.asax', which is deleted..
(Note that i published the API on Azure before with the Global.asax, but the new publish should overwrite everything)
I tried to clean/rebuild, deleted bin and obj and then re-publish, but i keep getting the error. I also verified that the Global.asax was properly deleted which is the case.
Do you have any clue ?
I followed your steps and reproduced your problem.
Note that i published the API on Azure before with the Global.asax
As you have said, you publish the API with Global.asax before, but when you republish it only overwrites the files you have changed.
When I delete the Global.asax locally and republish app, it still shows in the KUDU.
So I suggest that you could delete the Global.asax in KUDU.
Or when you publish your application, click "Remove additional files at destination".
Then your application will work fine.

Can a C# class-library read the web.config of a asp-classic web site?

I have a website which is build in Classic ASP. This website has a web.config file. I never created it, and never knew Classic ASP sites could have a web.config file, but this might be from IIS7 to store settings there.
This website uses a C# class library (DLL) to do some stuff. But here comes the tricky part. Should the DLL be able to read the web.config of this website?
I've copied the configSections from my app.config (from within the solution) to the web.config from the site. And also copied some settings (connectionstrings and applicationsettings). But when I changed the connectionstring to a faulty one, it would just keep running without a problem.
When I placed the configsections on the bottom of my web.config, the website wouldn't load because of a faulty web.config, so I the webserver is doing something with it. But can a C# DLL read this file also eventhough it's not a .NET website?
Thanks in advance.
As Chris said, asp classic does not use it, so it must have been created by IIS7 (or someone putting it there as a joke). That its not used if confirmed by your changing settings having no effect.
When you copied sections, the file becomes an invalid config; it's probably that which is causing it not to run, though what's checking it I don't know.
Another possibility is that the ASP website is using a C# library via COM Interop, and the run-time is checking its validity when it starts.

How Can I Host A WCF App In IIS?

I'm following Microsoft's tutorial on the topic here but it's not working and several items are unclear to me.
http://msdn.microsoft.com/en-us/library/ms733766.aspx
In step 2 it says, "ensure that ASP.NET has access to the contents of the folder". How can i do this?
Is it correct that the .cs code not be compiled? I've never ran .cs as a script of any kind.
Here is my error:
HTTP Error 404.17 - Not Found
The requested content appears to be script and will not be served by the static file handler.
Thanks.
Could you please ensure that your apppool in which your site is running in "Integrated" mode rather than Classic.
If the problem is not resolved after doing this, try to register your IIS with .netv4.0
For doing that
Go to Command Prompt
Go to the location C:\Windows\Microsoft.NET\Framework\v4.0.30319
Register the IIS using aspnet_regiis -i command
Open IISManager and go to handler mappings and right click on the static file and select "Revert to Parent"
You can Host a WCF App/Service in IIS as you host simple website. It seems to me that you are trying to access/browse .cs file. If so, then it is not possible as it is code file. You should browse only your service file i.e. .svc file.
You can refer http://adarshdchaurasia.wordpress.com/2013/09/26/create-restful-wcf-service-api-using-get-post-step-by-step-guide/ to create a WCF service.
Please ensure that:
You have .Net framework 4.0 installed and enabled on your machine. If
not, install or try to re-install. Sometimes re-installation fix the
unknown settings problem we accidentally create.
First try to host a simple demo web site to check if the problem is
with your WCF application or with hosting process your are
following.
In step 2 it says, "ensure that ASP.NET has access to the contents of
the folder". How can i do this?
I think it mean make sure your folder are accessible by the IIS_IUSRS
Check the publish folder properties -> Security tab -> group or user name.
Make sure the app is using application pool with correct .net framework version.
normally I will just set .net framework v4.0.30319

web service call fails

I have created a windows service application with C# with .Net 2.0, and added a web service as
http://localhost/postIncidents.ws.php?wsdl
It has the method "ReportIncident". I checked the windows service in local environment.
It worked.
Before I deploy it I added below code to get the particular url from a setting file.
shids_client.shidsWebServer.ReportIncident r = new shids_client.shidsWebServer.ReportIncident();
r.Url = Constant.readUrl();
r.CallReportIncident(time,LocalIPAddress(),type,line);
After I deployed, I added the URL to my setting file as
http://192.168.1.1/postIncidents.ws.php?wsdl
After I check it, it didn't work. the following error was in my log:
"Operation 'CallReportIncident' is not defined in the WSDL for this service"
if i remove it, then it will not show the wsdl xml. it will show only a rendered page.
You use the ?wsdl flag so that Visual Studio can download the WSDL and generate the service proxy. When the proxy actually runs, it runs against http:///postIncidents.ws.php, not ?wsdl needed. So try removing ?wsdl from the URL.

Categories

Resources