I am using api.cognitive.microsoft.com to extract text from images
I have the sample code from microsoft web site.
I did make a console project and configure the webApi and every thing is OK and I have the response
But when I make (or call) this code with MVC it don't work (I did make it directly and I did make it in console project and refer it on the MVC project)
The URL :
string uriBase = "https://westcentralus.api.cognitive.microsoft.com/vision/v2.0/ocr";
I don't know if it linked to the proxy because when I run it on the console application it's OK.
Any suggestions?
The sample code from this link :
Sample code
The error
The remote name could not be resolved: 'westcentralus.api.cognitive.microsoft.com'
I found the solution for my case.
It was about the proxy.
I did add this section to my webConfig:
<system.net>
<defaultProxy enabled="true">
</defaultProxy>
</system.net>
Related
I'm currently working on a .net core application that uses a azure service bus queue.
We are restricted to using AMQP over websockets and are behind a corporate proxy.
The QuietClient class does not provide anyway to set proxy information in any of it's constructors and we get a
"Cannot connect to remote server" error when we attempt to write a message to the queue.
The exact same code works when I use it from home - not behind a proxy!
In regular .net bypassing a proxy could be achieved by adding to default proxy configuration in the web.config.
<defaultProxy enabled="true" useDefaultCredentials="false">
<proxy usesystemdefault="True" proxyaddress="http://someAddredd:8888" />
......
</defaultProxy>
Because this is a .net core application the app doesn't use a web.config file for it's configuration.
When deployed to IiS a light weight web.Config file is created to allow the IIS to integrate with core's kestrel web server. However, adding the bypass proxy info to this does not work.
Any help would be much appreciated!
I just changed my laptop. I am moving my old project done in MVC 4 and was done in Visual Studio 2012. My current Visual Studio in my new laptop is 2017 version.
There is a problem when I want to debug my MVC application. This error comes out after I run the debug:
HTTP Error 403.14 - Forbidden The Web server is configured to not list
the contents of this directory.
Most likely causes: A default document is not configured for the
requested URL, and directory browsing is not enabled on the server.
I never set my application to be listed in directory browser. My application is an MVC application which will run global.asax and redirect to my home page.
How can I fix this?
enable directory browsing.
keep this into your web config file then rename the add value="pagename.aspx"
<system.webServer>
<defaultDocument>
<files>
<add value="yourpage.aspx" />
</files>
</defaultDocument>
<directoryBrowse enabled="false" />
</system.webServer>
or
<system.webServer>
<directoryBrowse enabled="true" />
</system.webServer>
You can also enable directory browsing from IIS
Open a command prompt, and then go to the IIS Express folder on your computer. For example, go to the following folder in a command prompt: C:\Program Files\IIS Express
Type the following command, and then press Enter:
appcmd set config /section:system.webServer/directoryBrowse /enabled:true
Got the same error, but MVC5 on VS2017. Eventually found I got the error because i had marked Application_Start() in Global.asax as a static. I did that because i made the mistake of following this Code Analysis recommendation:
This is a potential duplicate of
HTTP Error 403.14 - Forbidden The Web server is configured to not list the contents
Different context since you are trying to debug in IIS express and you are not hosting the application in IIS, however the error is the same and the answers is worth checking out. Could set you on the right path.
Would have commented but don't have enough rep yet.
Make sure you have defined your default application inside the hosts file in your new laptop.
This is a cause for many headache.
See it under:
C:/Windows/System32/Drivers/etc/hosts
I am trying to get my new asp.net core rc2 version running on my dev server that running IIs 8.5 and window 2012 server
I've followed the steps list in here, which is:
On my local:
Create a new asp.net core project using VS 2015 (Dev14) U2
Change the web.config stdoutLogEnabled="true", create a new deploy profile and publish it locally to a folder
Make sure the website works on IIS Express.
On my server
Installed the DotNetCore.1.0.0.RC2-WindowsHosting.exe and reset IIS
Setup new app pool with no managed code, setup new website in IIS that points to the local: D:\apps\myapp1\
Copy the deploy content to D:\apps\myapp1\ (such as the dll is D:\apps\myapp1\myapp1.dll)
dotnet.exe is on the path. I can even go to D:\apps\myapp1\ and dotnet myapp1.dll. It will bring up the nano server.
What I see when I hit http://mydevserver/myapp1 (or localhost/myapp1 on my dev server):
HTTP Error 502.3 - Bad Gateway
When I view the Event log, I can see a bunch of failure like this:
my logs folder on D:\apps\myapp1\logs is also empty. There is no log in that folder whatsoever.
At this point I am pretty lost on what to do. Help!!!
Here's the content of my web.config
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<!--
Configure your application settings in appsettings.json. Learn more at http://go.microsoft.com/fwlink/?LinkId=786380
-->
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified"/>
</handlers>
<aspNetCore processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%" stdoutLogEnabled="true" stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="false"/>
</system.webServer>
</configuration>
</xml>
There are a few things you can do to troubleshoot:
go to the published app and try running it without IIS
logs won't be written if the folder does not exist and by default the logs folder does not exist
if it is a portable app make sure the path to dotnet.exe is on the system wide %PATH% (note you need to do iisreset after you set it to make IIS pick it up)
I wrote a blog post explaining how ASP.NET Core apps work with IIS and the post contains the section on troubleshooting your very problem.
So I finally figured out what's wrong. Apparently because I did not setup my website under "Default Web Site" of IIS, so IIS (I think) routes my website incorrectly. My fix is to move my website under Default Web Site.
One of my friends found another way to setup the website outside of Default Web Site by disabling the Default Web Site. I have not tried to get both Default Web Site enable and MyApp website enable working. Maybe somebody else can contribute in...
I am calling a web service (for sms sending) in my asp.net web application. When my web application is on Developer Server, the web service is called and everything is fine, the expected results are returned. However, when the application is run on IIS, I cannot call the web service and I get this WebException:
"Unable to connect to the remote server"
And in details, InnerException, the message is "No connection could be made because the target machine actively refused it SomeIP:SomePort" where SomeIP is the web service IP address and SomePort is 80
(I was suspecting the problem is the port 80, since pinging SomeIP returns a response but Telnet on SomeIP SomePort fails. But I'm not sure if this is really the problem, I mean, how could the application set a different port when run on IIS!)
I really appreciate any help or ideas!
I had a similar issue wherein the unit test was successfully able to call the external web service, while the asp.net mvc application I was working on was unable to.
I had to a web.config entry to make it work. I am sharing the config entry, which I think, could help people with a similar issue. By the way, this section goes directly under the root element within web.config file. Replace proxy server name and port as applicable in your context.
<system.net>
<defaultProxy>
<proxy proxyaddress="http://<proxy server name>:<port>" />
</defaultProxy>
<!--<defaultProxy enabled="true" useDefaultCredentials="true">
<proxy usesystemdefault="True" bypassonlocal="True" />
</defaultProxy>-->
</system.net>
The deployment requirements for my app (a windows service written in C#) state the presence of a Proxy server.
From my interaction with the person who will install my app:
1. His company blocks access to internet via the proxy
2. He needs to provide the path to the proxy script in his IE Config.
3. He also needs to input a user-name/password.
My application needs to access a publicly hosted WebService. In preparation, I sent him a test Winform app. In the app.config file I used the setting mentioned in this post .NET client app: how to reach Web Services in case of proxy?
However, it did not work. I customized the proxy setting in App.config as per his IE settings, yet nothing seemed to work.
I don't want to hard-code the proxy settings in my app using the System.Net classes. There is no doubt in my mind that I want to use the config file.
So, I want to install a proxy on a VPC image and try and get my application to run.
My question:
1. What is a good proxy that I can install on my VM (windows only - no linux/squid pls.) that will replicate the behaviour that I mentioned in 2 & 3 above.
2. In case it is of interest, the proxy settings I used was:
<system.net>
<defaultProxy >
<proxy usesystemdefault= “False“ proxyaddress=“http://10.1.10.10:8080“ bypassonlocal=“True“ />
</defaultProxy>
</system.net>
Assuming that the system will read the settings from IE, I also tried
<proxy autoDetect="true" />
It did not work.
Pls. let me know if my requirements are unclear.
The open source squid proxy has Windows binaries.
If you have a Windows Server OS in you VPC, you could try out Microsoft's very own ISA Server. There's a 180-day trial version here.