ASP proper config to allow CORS in a asmx webservice for POST requests - web-services

I´m trying to setup a server capable to handle CORS, but also capable to return the response in json format.
Tried with various config schemes, but no luck.
I need to do my Ajax requests via POST. With my actual config i´m able to do requests via GET, but currently my response always is encapsulated in XML format.
As stated in ResponseFormat.Json returns xml , my requests must be 'application/json' but when I try to do it in this way I'm receiving a preflight message (Response for preflight has invalid HTTP status code 404).
My web.config (allowing CORS via GET) currently is:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.5.2">
<assemblies>
<add assembly="CrystalDecisions.Web, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692FBEA5521E1304" />
<add assembly="CrystalDecisions.Shared, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692FBEA5521E1304" />
<!--<add assembly="log4net, Version=1.2.10.0, Culture=neutral, PublicKeyToken=692FBEA5521E1304"/>-->
<add assembly="CrystalDecisions.ReportSource, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692FBEA5521E1304" />
<add assembly="CrystalDecisions.ReportAppServer.Controllers, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692FBEA5521E1304" />
<add assembly="CrystalDecisions.ReportAppServer.DataDefModel, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692FBEA5521E1304" />
<add assembly="CrystalDecisions.CrystalReports.Engine, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692FBEA5521E1304" />
<add assembly="CrystalDecisions.ReportAppServer.ClientDoc, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304" />
</assemblies>
</compilation>
<httpRuntime />
<pages controlRenderingCompatibilityVersion="4.0" />
<httpHandlers>
<add verb="GET" path="CrystalImageHandler.aspx" type="CrystalDecisions.Web.CrystalImageHandler, CrystalDecisions.Web, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304" />
</httpHandlers>
<sessionState timeout="30"></sessionState>
<webServices>
<protocols>
<add name="HttpGet" />
<add name="HttpPost" />
</protocols>
</webServices>
</system.web>
<appSettings>
<add key="CrystalImageCleaner-AutoStart" value="true" />
<add key="CrystalImageCleaner-Sleep" value="60000" />
<add key="CrystalImageCleaner-Age" value="120000" />
</appSettings>
<connectionStrings>
<....>
</connectionStrings>
<system.webServer>
<handlers>
<add name="CrystalImageHandler.aspx_GET" verb="GET" path="CrystalImageHandler.aspx" type="CrystalDecisions.Web.CrystalImageHandler, CrystalDecisions.Web, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304" preCondition="integratedMode" />
<remove name="ExtensionlessUrlHandler-Integrated-4.0" /><remove name="OPTIONSVerbHandler" /><remove name="TRACEVerbHandler" /><add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" /></handlers>
<validation validateIntegratedModeConfiguration="false" />
<httpProtocol>
<customHeaders>
<add name="Access-Control-Allow-Origin" value="*" />
<add name="Access-Control-Allow-Headers" value="X-Requested-With, Content-Type" />
<add name="Access-Control-Allow-Methods" value="GET, POST, PUT, DELETE, OPTIONS" />
</customHeaders>
</httpProtocol>
</system.webServer>
</configuration>
I´m using iron-polymer for the Ajax-requests and combined various content-types. Currently i´m getting my data via GET using 'content-type="application/x-www-form-urlencoded; charset=UTF-8" handle-as="document"'.
I´m having difficulties to process the response due such XML encapsulation. Below are two examples of received responses. How to extract the contents ?
1:
<?xml version="1.0" encoding="utf-8"?>
<string xmlns="http://my.domain/">EF7B48E346BC537F98F9696304CECAFE</string>
2:
'<?xml version="1.0" encoding="utf-8"?>
<ArrayOfCiudad xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://my.domain/">
<Ciudad>
<Codigo>32</Codigo>
<Nombre>BOGOTA</Nombre>
<CodigoDepartamento>Z03</CodigoDepartamento>
</Ciudad>
<Ciudad>
<Codigo>133</Codigo>
<Nombre>CALI</Nombre>
<CodigoDepartamento>Z01</CodigoDepartamento>
</Ciudad>
<Ciudad>
<Codigo>53</Codigo>
<Nombre>CARTAGENA</Nombre>
<CodigoDepartamento>Z13</CodigoDepartamento>
</Ciudad>
<Ciudad>
<Codigo>30</Codigo>
<Nombre>MEDELLIN</Nombre>
<CodigoDepartamento>Z04</CodigoDepartamento>
</Ciudad>
</ArrayOfCiudad>'

Related

How to run multiple django applications on IIS server?

I am new in django that runs on IIS server. I have manage to set up server that one django application/site is runnging..now I want to add another django application/site to this server. I cant find anywhere the sample web.config how to do that..
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<staticContent>
<mimeMap fileExtension=".apk" mimeType="application/vnd.android.package-archive" />
<mimeMap fileExtension=".config" mimeType="application/xml" />
<mimeMap fileExtension=".pdb" mimeType="application/octet-stream" />
</staticContent>
<handlers>
<add name="Python FastCGI"
path="/page1/*"
verb="*"
modules="FastCgiModule"
scriptProcessor="c:\python27\python.exe|c:\python27\lib\site-packages\wfastcgi.pyc"
resourceType="Unspecified"
requireAccess="Script" />
</handlers>
</system.webServer>
<appSettings>
<add key="WSGI_HANDLER" value="page1.wsgi.application" />
<add key="PYTHONPATH" value="C:\inetpub\wwwroot\page1" />
<add key="DJANGO_SETTINGS_MODULE" value="page1.settings" />
</appSettings>
</configuration>`
This is my config so far, how can I add another django site that will be available on URL/page2/ ?
To create a new site click on the server name and add a new website.
enter your site folder path and binding detail.
and copy your old web.config file to the new create site folder and make changes that you want.
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<staticContent>
<mimeMap fileExtension=".apk" mimeType="application/vnd.android.package-archive" />
<mimeMap fileExtension=".config" mimeType="application/xml" />
<mimeMap fileExtension=".pdb" mimeType="application/octet-stream" />
</staticContent>
<handlers>
<add name="Python FastCGI"
path="/page2/*"
verb="*"
modules="FastCgiModule"
scriptProcessor="c:\python27\python.exe|c:\python27\lib\site-packages\wfastcgi.pyc"
resourceType="Unspecified"
requireAccess="Script" />
</handlers>
</system.webServer>
<appSettings>
<add key="WSGI_HANDLER" value="page2.wsgi.application" />
<add key="PYTHONPATH" value="C:\inetpub\wwwroot\page2" />
<add key="DJANGO_SETTINGS_MODULE" value="page1.settings" />
</appSettings>
</configuration>
Note: use python version after 3.6 with iis if possible.

I can not upload files larger than 35 MB aprox with webserviced + IIS

I have a website (ASP.NET core) with an ajax + base64 function to upload files.
When I pick a file from 0-29 MB aprox works perfect, but If i pick a larger file, does not upload.
My web.configs;
Web.config (app side)
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath=".\AppName.exe" arguments="" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="true">
<environmentVariables />
</aspNetCore>
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="1073741824" />
</requestFiltering>
</security>
<rewrite>
<rules>
<rule name="HTTP A HTTPS" enabled="false" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="^OFF$" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}" appendQueryString="false" />
</rule>
</rules>
</rewrite>
</system.webServer>
<system.web>
<!-- <httpRuntime maxRequestLength="2147483647" /> -->
</system.web>
</configuration>
And web.config (webservice)
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<appSettings>
<add key="..." value=".....=" />
<add key="..." value=".....=" />
<add key="..." value=".....=" />
<add key="..." value=".....=" />
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.5.2" />
<authentication mode="Windows" />
<pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID" />
<httpRuntime maxRequestLength="2147483647" maxQueryStringLength="2097151" />
</system.web>
<system.webServer>
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="1073741824" />
</requestFiltering>
</security>
</system.webServer>
</configuration>
I tried some parameters that I found in other questions like this. maxAllowedContentLength,maxRequestLength, maxUrlLenght... but any works.
I think maxAllowedContentLength="1073741824" should be 1 GB aprox.
But I do not if it is correct.Neither if change would be in web.config site,web.config webserver or both.
Any idea?
Thanks!!

Nuget Server Repository - Page not found 404

I'm totally desperate. I've been trying to install Nuget.Server v3.2.1.0 for two days now.
I followed the installation instructions at https://learn.microsoft.com/de-de/nuget/hosting-packages/nuget-server, but it doesn't work.
I suspect that the routing doesn't work properly.
My Web.config looks like:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.web>
<compilation strict="false" explicit="true" debug="true" targetFramework="4.6" />
<!-- maxRequestLength is specified in Kb -->
<httpRuntime targetFramework="4.6" maxRequestLength="30720" />
</system.web>
<appSettings>
<add key="aspnet:UseHostHeaderForRequestUrl" value="true" />
<add key="requireApiKey" value="true" />
<add key="apiKey" value="MyApiKey" />
<add key="packagesPath" value="D:\TFS-Workspaces\Fachit360\Playground\NuGet Server\NuGet Server\Packages" />
<add key="cacheFileName" value="" />
<add key="allowOverrideExistingPackageOnPush" value="false" />
<add key="ignoreSymbolsPackages" value="true" />
<add key="enableDelisting" value="false" />
<add key="enableFrameworkFiltering" value="false" />
<add key="enableFileSystemMonitoring" value="true" />
<add key="allowRemoteCacheManagement" value="false" />
<add key="initialCacheRebuildAfterSeconds" value="15" />
<add key="cacheRebuildFrequencyInMinutes" value="60" />
</appSettings>
<system.codedom>
<compilers>
<compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:default /nowarn:1659;1699;1701" />
<compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:default /nowarn:41008 /define:_MYTYPE=\"Web\" /optionInfer+" />
</compilers>
</system.codedom>
<system.webServer>
<handlers>
<remove name="ExtensionlessUrlHandler-Integrated-4.0" />
<remove name="OPTIONSVerbHandler" />
<remove name="TRACEVerbHandler" />
<add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
<remove name="WebDAV" />
</handlers>
<staticContent>
<remove fileExtension=".nupkg"/>
<mimeMap fileExtension=".nupkg" mimeType="application/zip" />
</staticContent>
<modules runAllManagedModulesForAllRequests="true">
<remove name="WebDAVModule" />
</modules>
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="31457280" />
</requestFiltering>
</security>
</system.webServer>
<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
</system.serviceModel>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
...
</assemblyBinding>
</runtime>
</configuration>
And here is my development environment:
- Visual Studio 2017 Pro (15.9.12)
- Windows 10 Enterprise LTSC
- IIS Express 10.0 (Visual Studio integrated)
The installation is very simple. The overview page is also displayed:
What I find confusing is that the Default.aspx file contains the following:
Click here to view your packages.
And in the file NuGetODataConfig.cs the following is configured:
NuGetV2WebApiEnabler.UseNuGetV2WebApiFeed(
config,
"NuGetDefault,
"nuget"
"PackagesOData,
enableLegacyPushRoute: true);
Anyway, when I click on "Click here to view your packages", I get the error: "Page not found - 404".
Does anyone have an idea why that might be? I am at the end of my Latin.
Many greetings
Update
I forgot to mention that I also tried to release the project on a Windows Server 2012 R2. Exactly the same problem.
And it's strange that you can find the following packages in my project references:
- Nuget.Core
- Nuget.server
- Nuget.Server.Core
- Nuget.Server.V2
Then why does the start page talk about Nuget.Server 3.2.1.0?

HTTP Error 500.0 - Internal Server Error Django on iis Error Code 0x00000067

I'm trying to makedjango web app work on IIS using wfastcgi
Following This guide it gave me the error code 0x00000067
and here is my web.config file :
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="AccuManager" path="*" verb="*" modules="FastCgiModule" scriptProcessor="E:\projectInnoventiq\accuManager\venv\Scripts\python.exe|E:\projectInnoventiq\accuManager\venv\Scripts\wfastcgi.py" resourceType="Unspecified" />
</handlers>
<httpErrors errorMode="Detailed" />
<tracing>
<traceFailedRequests>
<add path="*">
<traceAreas>
<add provider="ASP" verbosity="Verbose" />
<add provider="ASPNET" areas="Infrastructure,Module,Page,AppServices" verbosity="Verbose" />
<add provider="ISAPI Extension" verbosity="Verbose" />
<add provider="WWW Server" areas="Authentication,Security,Filter,StaticFile,CGI,Compression,Cache,RequestNotifications,Module,FastCGI,WebSocket" verbosity="Verbose" />
</traceAreas>
<failureDefinitions timeTaken="00:00:00" statusCodes="500" />
</add>
</traceFailedRequests>
</tracing>
</system.webServer>
</configuration>

I am facing issues while hosting my Flask web application in IIS

I am using Python3.5, IIS10 to deploy flask web application in iis. Can anyone help me to set up iis with python. I saw many examples but i could not able to do so. I guess the error must be related to web.config
My error is
HTTP Error 500.0 - Internal Server Error C:\Program Files\Python35\python.exe - The FastCGI process exceeded configured request timeout
web.config
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<appSettings>
<add key="WSGI_HANDLER" value="Bot_Chat.app" />
<add key="PYTHONPATH" value="C:/inetpub/wwwroot/EtownChatBot/;C:\Program Files\Python35;C:\Program Files\Python35\Lib;C:\Program Files\Python35\Lib\site-packages;C:\Program Files\Python35\DLLs;" />
</appSettings>
<system.webServer>
<handlers>
<remove name="CGI-exe" />
<add name="FlaskHandler" path="*" verb="*" modules="FastCgiModule" scriptProcessor="C:\Program Files\Python35\python.exe|"C:\inetpub\wwwroot\EtownChatBot\wfastcgi.py"" resourceType="Unspecified" />
</handlers>
<directoryBrowse enabled="true" />
<security>
<requestFiltering>
<fileExtensions>
<add fileExtension=".py" allowed="true" />
<add fileExtension=".html" allowed="true" />
</fileExtensions>
</requestFiltering>
</security>
</system.webServer>
</configuration>
Add applicationHost.xdt under Your Project directory..
applicationHost.xdt
<?xml version="1.0"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<system.webServer>
<fastCgi>
<application xdt:Locator="Match(fullPath)" xdt:Transform="SetAttributes(activityTimeout)"
fullPath="C:\Program Files\Python35\python.exe" activityTimeout="600"/>
</fastCgi>
</system.webServer>
</configuration>
Refresh and Restart your Site.Now it will work..