"CommunicationException was unhandled by user code" when deploying web application to IIS - c#

I am new to IIS and Silverlight. I followed this tutorial to create a web application using Visual C#2010 and IIS 7.
The application is working perfectly when in visual studio using IIS express. When I deploy to Local IIS it shows this error:
CommunicationException was unhandled by user code. An error occurred
while trying to make a request to URI
'http://localhost:55826/WebService1.asmx'
This could be due to attempting to access a service in a cross-domain
way without a proper cross-domain policy in place, or a policy that is
unsuitable for SOAP services. You may need to contact the owner of the
service to publish a cross-domain policy file and to ensure it allows
SOAP-related HTTP headers to be sent. This error may also be caused by
using internal types in the web service proxy without using the
InternalsVisibleToAttribute attribute. Please see the inner exception
for more details.
How can I deploy a web app based on MySQL to IIS without encountering this error?

You need to make the service available across domains when deployed. For this, you need to add a crossdomain.xml and a clientaccesspolicy.xml files to your web project. You can find more details here : https://msdn.microsoft.com/en-us/library/cc197955(VS.95).aspx

Related

Hosting WCF service on IIS7.5, receiving 404.0 error

I just received a new development laptop and now I can't get one of my WCF services running on the new laptop.
Windows 7 Enterprise
IIS 7.5.7600.16385
Windows Features Installed:
Internet Information Services
Web Management Tools
IIS 6 Management Compatibility
IIS Management Console
IIS Management Scripts and Tools
IIS Management Service
World Wide Web Services
Application Development Features (all sub-features)
Common HTTP Features
Default Document
Directory Browsing
HTTP Errors
HTTP Redirection
Static Content (all sub-features)
Health and Diagnostics (all sub-features)
Performance Features (all sub-features)
Security (all sub-features)
Internet Information Services Hostable Web Core
Microsoft .NET Framework 3.5.1 (all sub-features)
Windows Process Activation Service (all sub-features)
I dropped a simple "Hello World!" index.html file at the root of the WCF services application. I am able to serve that .html file. My services are under a sub-directory named "Hosts". I also dropped a simple index.html file under that sub-directory - I am able to serve that file as well. I cannot serve any of my .svc files though.
http://localhost/mywcfapplication/Hosts/IncidentService.svc
Anonymous Authentication -- "Application pool identity" is selected
The services are running in their own application pool. About the app pool:
.NET Framework Version: v2.0
Enable 32-bit applications: false
Managed Pipeline Mode: Classic
Identity: ApplicationPoolIdentity
I recently set these services up on a new Windows Server 2012 R2 web server in our test environment (old test server was decommissioned). On the server I had to give the app pool user permission to the directory in the file system (IIS_IUSRS\apppoolname), but my laptop doesn't seem to like this.
I'm receiving a 404.0 error when I attempt to browse to any of my .svc files under this application. IIS tells me the most likely causes are: •The directory or file specified does not exist on the Web server.
•The URL contains a typographical error.
•A custom filter or module, such as URLScan, restricts access to the file.
I have checked and re-checked the URL, and I can serve the .html files. I verified that the .svc files do exist. I'm at a loss. What have I overlooked?
Research:
IIS7.5 WCF Service - HTTP Error 401.3 (Even after adding IIS_IUSRS)
Hosting WCF service on IIS7.5
Windows 7 IIS7.5 and asp application Error HTTP 404.0 - Not Found
UPDATES:
6/8/15 - I added IIS AppPool\AppPoolName to the IIS_IUSRS group. No change.
6/9/15 -
I ran servicemodelreg -i. No change.
https://msdn.microsoft.com/en-us/library/ms752252(v=vs.90).aspx
Because I'm getting desperate, I ran aspnet_regiis –i –enable and then "%WINDIR%\Microsoft.Net\Framework\v3.0\Windows Communication Foundation\ServiceModelReg.exe" -r
I also followed the steps listed "to verify that the svc file type is mapped correctly in IIS7.0"
HTTP 404 when accessing .svc file in IIS -- "We had a similar problem, and the SVC handler was already correctly installed. Our problem was the ExtensionlessUrl handler processing requests before they reached the SVC handler. To check this - in Handler Mappings in IIS Manager at the web server level, view the list of handlers in order (it's an option on the right-hand side). If the various ExtensionlessUrl handlers appear above the SVC handlers, then repeatedly move them down until they're at the bottom."
I verified that the extensionless handlers were at the bottom.
At the advice from yet another forum post I added a MIME type for .svc. No change.
6/15/2015 -
- Log file: u_ex150615.log
I got exactly the same issue and finally found a way through it.
The point is that WCF need a integrated pipeline to work properly. In Windows 7's IIS 7.7 I solved the problem by setting the Application Pool to use Integrated Pipeline mode (it was in Classic Mode). But Windows Server 2003's IIS 6 doesn't work with integrated pipeline, so Microsoft .Net uses Web Services Extensions, you could check at IIS 6, right above Web Sites. Ensure that the desired .Net version is allowed in Web Services Extensions. Than you need to register the Service Model extension.
Here´s what I did:
%windir%\Microsoft.NET\Framework\v2.0.50727\aspnet_regiis.exe -i
%windir%\Microsoft.NET\Framework\v3.0\Windows Communication Foundation\ServiceModelReg.exe -i

How to run an asp.net application in local IIS

I am kind of new to asp.net.
I have created an application using Visual studio 2013 Web Express and MVC5. When I wanted to run the application, I was pressing the run button from VS and it managed to open it.
Now I switched the server from IIS Express to Local IIS. When I run the application in the browser, it gives me
Server Error in '/' Application. <br>
Access is denied.
Description: An error occurred while accessing the resources required to serve this request. The server may not be configured for access to the requested URL.
Error message 401.2.: Unauthorized: Logon failed due to server configuration. Verify that you have permission to view this directory or page based on the credentials you supplied and the authentication methods enabled on the Web server. Contact the Web server's administrator for additional assistance.
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.18446
I guess because I don't have like Default.aspx file or something, I don't know what is the problem ??
This is a permissions issue. When you develop and run an application inside visual studio it has all the rights it needs. So you need to configure iis when wanting to demo/use the site directly from the webserver. After you have made the application inside IIS -> select the application and in the Actions pane you should see the link 'Edit Permissions'. Clicking that brings up the properties tab and under security add your account or an administrator account and elevate the rights until the site works.
I managed to get it working.
The problem was, I am using windows authentication to access the web application (VS asked me when the project first created). Now I didn't know I need to set it in the iis too.
All I did is enabling the Windows Authentication in iis > MySite > Authentication.

Insufficient permissions for setting the configuration section 'defaultProxy'

I am trying to access a windows application (which uses the .NET 2.0 framework) from the share folder. The application connects to a web service.
There is no proxy between the application and the web service (on either the remote machine or on the local machine).
When application tries to access any web method I am getting following error:
Insufficient permissions for setting the configuration section 'defaultProxy'.
I heard there was a hot fix from Microsoft but didn't find anything on the site.
Please suggest how to resolve the problem.

Consuming Windows Authenticated Service for Client Development in Visual Studio

I have a service hosted in server. The service authentication is using Windows Authentication. I want to use this service in my website development in Visual Studio 2010. When I try to add a reference it says the following error.
“Security settings for this service require Windows Authentication but it is not enabled for the IIS application that hosts this service.”
What should I do to overcome it and be able to consume the service for development?
Note: The error message is obvious. What I am looking for is the best way to overcome this.
Note: When I type the service address in Mozilla Firefox, it asks for my windows credentials -upon entering credentials it gives me the service descriptions. The problem is when I use it via Visual Studio.
If I understand you correctly, your service is already running happily and using Windows Authentication, so it requires the calling application, your web site to also be using Windows Authentication.
When you try and add a reference, VS will start your site in the background using whichever web server is defined in Project Properties. You say that you are starting your site using the built-in web server (also known as Cassini or Webdev). You need to ensure that your site is using Windows Authentication. You do this from the service's Project Properties (right-click on the root folder and select Properties). In there you will see a Web tab which has an NTLM Authentication checkbox - make sure that is checked.
Also, make sure that you use:
<system.web>
<authentication mode="Windows">
...
in your web.config.
However, if you want to use IIS itself, I assume you have it installed and know how to define a web application. Depending on which version of Windows you are running, you may or may not have IIS installed or it may not be installable (using Programs and Features from Control Panel). If you don't have IIS, you can install IIS Express from here: http://learn.iis.net/page.aspx/868/iis-express-overview/
After you have installed IIS and defined your application root, and pointed the directory to your local source folder, enable Windows (NTLM) Authentication for that web app/site. How you do that depends on which version of IIS you are running but it is normally by clicking on the Authentication icon. You probably need to disable Anonymous as well as enable Windows Authentication, so that all requests are forced into Windows authentication. For browsers that do not support automatic NTLM authentication, I also turn on Basic Forms authentication as well.
Once you have an IIS application defined, you can use that for debugging from Visual Studio instead of the built-in web server. You also do that from Project Properties by choosing 'Use Local IIS Server' and selecting the Url of the IIS site you created above. Alternatively, VS can create the IIS site definition for you if it doesn't yet exist.
Either of the above methods should ensure that when VS starts your site to add a reference, it will be using authentication, as well as at runtime. Note that you can add a reference manually, without the need for starting the site. Then you just need to make sure you have Windows authentication at runtime, as described above.

How to enable Windows Authentication on ASP.NET Development Server?

We are trying to host a WCF service via the web. We set the web.config to have the service require windows authentication. The problem we are having is the following:
When we host our service in a regular IIS, the service runs fine and there is no issues with the "Windows Authentication" mode. However, when we try to run it from our developer boxes we get the following error: "Security settings for this service require Windows Authentication but it is not enabled for the IIS application that hosts this service."
Our developers boxes are not hosting the service through the regular IIS but rather through Visual Studio's ASP.NET Development Server. We tried going into the web project properties and said to enable NTLM authentication but that still did not fix it. Does anyone know how to fix it? Does VS ASP.NET Development Server even support Windows Authentication? Is the only option for hosting the service with Windows Authentication is to use IIS and forget about ASP.NET Development Server?
In order to configure IIS Express security settings:
look for the IIS express symbol in the taskbar (system tray).
Right click and select "All Applications".
Click on the name of the site you want to change (although I believe the change is site wide)
Click on the path in the config section below (it will open the applicationhost.config file)
Search for the authentication section and make your changes
Example changes can be found here:
http://toadcode.blogspot.ca/2011/08/security-config-in-iis-express.html
ASP.Net Development Server is very limited. It only serves requests originating from the same machine that it is running on, and it will not serve files that are outside of its application scope. It is based on the Cassini server. Cassini does not support WCF web services. Documentation for ASP.Net Development Server says that it does support NTLM. If you are just browsing to a page from the local machine it should work fine unless the page is referencing an unavailable resource.
check out http://msdn.microsoft.com/en-us/library/58wxa9w5.aspx for more info.
I would install and configure IIS on your local dev machine and use that in preference to using the inbuilt webserver. To use local IIS to debug select "User Local IIS web server" on the web tab of the project properties. Using IIS rather than the inbuilt webserver also means that you can configure your app in exactly the same way as it will be configured on the production server and this will reduce the no of potential surprises when you move to the production environment.
The solution to my authorization issue was to go into the F4 project properties and set the following:
Anonymous Authentication: Disabled
Windows Authentication: Enabled
Apparently these properties update the IIS applicationHost.config directly.
http://provenstyle.com/blog/2015/10/02/Visual-Studio-2015-Windows-Authentication-And-IIS-Express/

Categories

Resources