Human readable URL in azure - c#

I have an azure cloud service with a couple worker roles, a WCF web role and a normal web role containing a couple aspx pages. Both roles are set to use https endpoints.
When testing locally in Visual studio using IIS the default.aspx page and the servicename.svc page both open in the browser. When I publish to azure though, the URL with the random string of characters opens the directory containing the service definition, but I can’t access the default.aspx page from that URL.
For example if my URL is randomstring.cloudapp.net after publishing, randomstring.cloudapp.net/wcfservice.svc works, but randomstring.cloudapp.net/default.aspx does not. I can get to the other page by using the IP address given in azure, but this isn’t really what I need. Furthermore, the cloud service URL does not work at all. mycloudservice.cloudapp.net results in webpage not found.
Do I need to do something special in order to get both the service, and the aspx pages to show up under mycloudservice.cloudapp.net? I can post the config files if need be, but as of right now, I don't think there relevant to the problem.
EDIT:
Just to clarify, I have now published to production, and the service is working [mycloudservice].cloudapp.net/[mywcfservice] and I can get to the website without a 404 error if I enter the port like [mycloudservice].cloudapp.net:8081/default.aspx . Is there a way to make everything show up under [mycloudservice].cloudapp.net/ without entering the port number so I can just type in [mycloudservice].cloudapp.net/[mywcfservice] AND [mycloudservice].cloudapp.net/default.aspx into the browser?

First, I guess you published your project to the stage slot of your cloud service. It's [Deployment ID].cloudapp.net. You will use the URL you specified if you deploy it to production slot.
Ref the problem, that '[randomstring].cloudapp.net/default.aspx' doesn't work, I'm not sure what you mean by 'doesn't work'. Is it 404 erroe? Or some asp.net runtime error. More information might be helpful.

Check the port numbers. Each of the endpoints (the wcf endpoint and the web endpoint) need to be on different port numbers. You'll need to access them as such when published to Azure.
The random-name issue is from publishing to Staging vs Production, as #Shaun pointed out.

Related

Deploy WebAPI to external website

We have a public website that is already exposed to the outside, although in reality there's really nothing there. Simply default.htm file with "Coming Soon" text in it. (http://vensuresoftware.com/)
We also have a WebAPI we've put together that we want to add to this website. When I publish locally to my IIS6, it works no problem. It's accessed as http://localhost/HRConnect/api/Claims just fine. I've used PostMan, a C# client, and Javascript AJAX to access this just fine. I can also load it in a browser at that URL, and I get the appropriate default controller and action.
However, I have been totally unable to accomplish this same thing on the website. Ideally I'd like to include it as a Virtual Directory to the http://vensuresoftware.com and access it as http://vensuresoftware.com/HRConnect/api/Claims but I've had zero luck doing so.
I have tried to add it as a Virtual Directory as well as an Application under that specific website, but when I access the URL, all I get is "The resource you are looking for has been removed, had its name changed, or is temporarily unavailable."
I've ensure the Application pool is correct, with an appropriate user and the pass through connection test succeeds. But I just cannot access the service or the URL.
Any ideas or suggestions at all on what I can try? I'm not sure what else I can include here. Nothing special in IIS, nothing special in the service really. There's only 3 actions in it. As I said, it all works beautifully locally, under localhost though.
IIS 7 doesn't have built-in support for extensionless URLs which causes a lot of headaches trying to get MVC and Web API apps to run. I've gotten it to work using both these options. Pick the one that applies to you.
Install this IIS patch which allows IIS 7 to handle extensionless URLs.
If the patch isn't an option because you're worried about breaking other sites on the server, you can make the Web.config adjustment found in this answer. You'll have to do this for every MVC/Web API app you have running on the server.

Load Testing Azure Web App with OAuth2

I'm trying to wrap my brain around setting up load testing secure azure web applications. I want to push a load test to the cloud, which is pretty simple given we are using VS online. However, when running multiple users I get several errors. I think the errors revolve around a single account trying to gain authorization to web app simulated with multiple 'virtual users.'
Errors: https://login.microsoftonline.com/common/login----{POST} Context parameter $HIDDEN1.ctx not found in test context
https://mysite.azurewebsites.net/----{POST} Context parameter $HIDDEN1.code not found in test context
a slew of socket exceptions:
https://localhost:port/skypetoc/v1/pnr/parse----{POST} connection actively refused
ValidateResponseUrl errors
https://mysite.azurewebsites.net/----{GET} The value of the expectedresponseUrl property 'https://login.microsoftonline.com/common/oauth2/authorize does not equal the actual response url https://mysite.azurewebsites.net querystring parameters were ignored.
running this test locally with a single user account works fine. pushing to the cloud under a single login account with multiple simulated users yields all these errors.
Questions:
1. Do I need to create n number of user accounts for this to work properly?
2. Do I just need to create custom plugins at the request level to get new auth tokens per user request?
3. Is there any built in support for this kind of stuff in Visual Studio Online Azure load testing?
I really don't want to test the performance of login since its out of my hands. but I do want to test the performance of my web app under load for other functions.
Visual Studio Online does not allow localhost to be the hostname in your callback URL. You can edit the hosts file on your local computer to map a hostname to 127.0.0.1. Then use this hostname when you register your app. Or, you can deploy your app when testing to a Microsoft Azure website to be able to debug and use HTTPS for the callback URL. See: https://www.visualstudio.com/en-us/integrate/get-started-auth-oauth2-vsi.aspx

WCF Service with Web Page not possible?

I have created a WCF Service and it's running just fine. I have the link that takes you to the Manager Service page in order for someone to get the URL for this service.
I have added a controller/cshtml page in order to test (ping) the databases that are used by the service so that we can check if they're up and running (the databases that is).
When I run the service locally with IIS Express, it works just fine.
www.domanin.com/ServiceName/Manager.svc is the URL.
When I run locally this ping (cshtml), it's localhost:XXXXX/Status.
Status is the name of the controller. And this works! (when I run locally).
Why does it not work when I publish it to a Server?
I try to go to www.domain.com/ServiceName/Status and I get a page cannot be found. I've also tried www.domain.com/Status and nothing. Can you not have a razor (cshtml + controller) hosted together with a service?
Thanks!
It sounds like your routing is not configured correctly most likely your mixing your wcf and mvc configurations and somehow it got messy. If you add .cshtml as an iis mime type on that remote server I suppose you could see a response.
I suggest that you create a folder under the root and make another iis application and place the test app and configuration in its own location if that is possible. You can still share code that way but will not have the overhead of opening the mvc pipeline for requests to your wcf service.

WCF webservice running on a two server cluster, with loadbalancer, resolving web service address

Apologies for the long winded title but looking for a solution to what might be a common problem.
We have a loadbalancer with address, say: www.myloadbalancer.com
Below are two web servers
First server: webserver1.farm.com
Second server: webserver2.farm.com
We deployed a webservice on to the two servers but noticed something funny when trying to consume the web services somewhere else.
We deploy to:
webserver1.farm.com/service1.svc and
webserver2.farm.com/service1.svc
Because the web servers are not directly accessible online you have to go through the load balancer.
So the address to consume is www.myloadbalancer.com/service1.svc.
However what we are finding is that if the loadbalancer directs you to server 1, and you check the WSDL, you see the service name and details as webserver1.farm.com/service1.svc not www.myloadbalancer.com/service1.svc.
If you attempt to consume www.myloadbalancer.com/service1.svc, say in Visual Studio 2008, you get a warning that webserver1.farm.com/service1.svc does not exist.
The main question is, is it possible to give an alias name to a webservice.
in other words is it possible to get the service to describe itself as www.myloadbalancer.com/service1.svc regardless of whether we end up on web server 1 or 2?
A WSDL file is a WSDL file. Edit it to point to the correct URL. (You don't have to use the auto-generated http://webserver1.farm.com/service1.svc?WSDL if you don't want to.)

.NET Web Service - Host name resolving improperly

Duplicate: This is the exact same question, from the exact same person, as Issue with Incorrect URLs in the WSDL of a .NET Web Service, and has the exact same answer. Let's please close this and merge it with the other.
We have installed an ASP.NET web site on a client's server. This site has a web service with a couple of web methods that are called by a Flash object in order to display a news feed. If you browse to their site (ex: www.domain.com), everything's working fine except the flash.
The issue is that when we browse to the .asmx, the header shows that the Host is a subdomain internal to their network (internal.domain.com). Obviously this doesn't resolve to any public IP when browsing from outside of their network. This causes the Flash to fail since the flash object is embedded on a page and is therefore running client side.
I checked the computer name on the server in question, and it doesn't even match "internal.domain.com" - it is something completely different. Where is it getting this information from. It is not coming from IIS, since we have no host headers set up, and the IP for the site is set to (all unassigned).
We either need to force the web service to run against a specific host, or we need to change something on the server so that it resolves to a valid public-facing host name. Any and all help is greatly appreciated!!!!
Web service host names are usually configured in the web.config when being consumed by .NET. When they are being consumed by flash you might need to go looking in the flash file. (my guess is that it is still configured for some sort of SIT environment.
I'm not sure of the details of this, but I've seen this complaint with respect to WCF. The answer had to do with setting the host headers in IIS.
It's IIS that passes the host name to ASP.NET or WCF, and it passes the host header when that is configured. If it's not configured, then I suppose it won't send that header as the "host name", even if the client sets that header in the request.

Categories

Resources