I have an ASP.NET MVC application in a solution, and inside the same solution there is another webservice project. I need to debug a particular WebGet method inside that service using a url in my localhost. Am able to reach the web service where it is hosted using the actual url to that service. But if I have to debug it, how can I reach that method when running in localhost?
You need to use IIS Express How to: Specify the Web Server for Web Projects in Visual Studio. Using IIS express you can debug and run both projects in your solution at the same time.
IIS Express for Developers
Related
What is the best approach to consume WCF external service data from SharePoint 2010 Web part?
Since you're in a Visual Studio solution, you just have to :
Right click on the "References" of the projet WebPart.
Click on Add Service Reference
Put the url of your Web Service then click on OK.
Visual Studio'll generate a service client proxy. Use it to call your Web Service
More information here
https://msdn.microsoft.com/library/bb628652(v=vs.100).aspx
I have a question as to how the Visual Studio 2013 debug emulator for Web API works.
I had built a Web API project in Visual Studio 2013 to access a database on an external server. The code was built using VS2013's ASP.NET Web Application project template for a Web API application. Once built, running debug opened a browser window for localhost port 56618, which allowed access from Fiddler to test Http requests.
Once I had the project finished, I published it to a website using Web Deploy to IIS. However, whilst the page would open (now at localhost:9812), an http request would throw an Internal Server Error 500.
Perusing the IIS FailedReqLogFiles, I noticed that the reason that it was failing was that the database server was refusing access to '<Domain>\<machine-name>$'.
I added '<Domain>\<machine-name>$' as a valid login (windows authentication, as the connection string included "Integrated Security=true") on the sql instance with read and write privileges, and the problem was resolved.
The question is, why didn't the Visual Studio debug emulator have the same issue?
Because the emulator was running the website under the context of your own account (e.g. <Domain>\You). Your account had access to the database, so there was no issue.
When you published it to IIS, it started running under the context of a different account (<Domain>\Machine-Name - but there are other variants depending on how IIS is configured, and the version of IIS), which didn't have access to your database.
I have a WebApi project that wraps the Dynamics CRM Online web service and provides a REST api. I have a simple controller that gets some contacts from CRM and returns them to the caller.
Everything works fine when I run it in the local emulator. However, when I deploy the project to Azure, I can reach the home page, but the controllers all return http 500 errors. Why would this happen? And how can I troubleshoot to get more details?
UPDATE
The issue is with the absence of Microsoft.IdentityModel.dll on the Server 2012 instance running the web role in Azure. I found this by opening web role instance in RDP, installing Fiddler, and making the request from Fiddler to the local IIS server. It responded with the detailed error.
Now my issue is figuring out how to enable IdentityModel on a Windows Azure Web Role. You're supposed to be able to add it via the Server 2012 Add Roles and Features wizard, but it's totally locked down on the Web Role. You can't check any boxes that aren't already checked. Is this even possible?
The issue is giving the Web Role access to Windows Identity Foundation when it's inherently not there. Marc Schweigert provides clear steps to do this here:
http://blogs.msdn.com/b/devkeydet/archive/2013/01/27/crm-online-amp-windows-azure-configuring-single-sign-on-sso.aspx
Go to the 23:00 mark of the video and you'll see the 4 necessary steps:
Reference Microsoft.IdentityModel.dll (need WIF SDK installed)
a. Set copy local = true
Create RegisterWIFGAC.cmd in your web role project
Create Startup Task in ServiceDefinition.csdef that invokes RegisterWIFGAC.cmd
Add GacUtil to the project (used in the startup task) to put Microsoft.IdentityModel.dll in the GAC every time the web role starts).
I am used to creating traditional WCF services and hosting them in IIS. I do this by creating a WCF Service Application within Visual Studio.
For my next project I want to leverage the functionality found in the new WCF Web API. However I am not sure what type of project I need to create to host the service.
Nearly all the examples I have read/seen show the service hosted in a ASP.NET Empty Web Application. Is this correct? Can I not host in in a WCF Application project and add the Web API references in that from NuGet?
I did try hosting in a WCF Application but soon fell over when it came to routing and the MapServiceRoute call in the Global.asax file which gets called on Application_Start.
Any help on this would be much appreciated.
For what I gathered from the samples, you can create the WCF as you have been creating, that is, a WCF Service Application in the WEB folder of Visual Studio.
I have a test web service replicating a live web service that hasn't been made public yet (It will be public when the app is released).
I added a new ASP.NET Web Service Application to my solution. Now when I try and add a web reference from the main project and choose "Browse To Web services in this solution" it doesn't find the test web service.
Am I missing an important step here?
Maybe the webservice you're trying to connect to isn't running . Do an F5, verify that the service has started by checking the address in the browser then try to add the refference again.
If it doesn't work, just specify the address by hand.