Deploy WebAPI to external website - c#

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.

Related

OutputCache with Redis working on Localhost but not Azure WebApp

I'm writing a standard MVC 5 application, and set OutputCache tag on the controllers, also installed StackExange.Redis and RedisOutputCache. Configured the web.config accordingly.
The cache works perfectly when I Run this in localhost, however once deployed into an Azure WebApp, the cache doesn't work as I See the changes coming through. Also when debugging the App remotely, i see the breakpoint hits in the controller view action.
I have been looking for days for a solution, but I could not find any answer, not even something similar. I already raised a ticket on Azure Support.
So my questions is, is there something that could make the Azure WebApp behave differently from the local solution?
How could I debug Outputcache to check why it doesn't hit the cached version?
Additional info: I see in the Redis Cli the that Outputcache is storing the cached version, it's just it doesn't return it.
Thanks
Well, I finally found the issue.
I was using Thread.CurrentThread.CurrentCulture.Name in the VaryByCustomString() function in global.asax to create a culture based cached version.
However, once deployed to Azure WebApp this culture appears to be not set, so the check fails and the OutputCache thinks there isn't any version in Redis.

Callback URL in Skydrive API to localhost

I am trying to implement SkyDrive API into my Asp.net mvc3 application.I tried to create app in Microsoft using this tutorial for implementing user authentication , but I am facing a problem in Callback Url, because Microsoft forces me to add a real domain and I want to use my localhost in order to develop it right now.
Alternatively you could add a fake domain to your
/etc/hosts (Linux)
C:\Windows\System32\drivers\etc\hosts (windows)
file. Just add the following lines:
127.0.0.1 www.yourfakedomain.de
After adding that line you can choose in Microsoft OneDrive App-Center something like
http://www.yourfakedomain.de/blabla.php
as your redirect uri.
Since your operating system thinks that domain belongs to localhost you will be able to get your authentication code just normally at your local test domain ;-)
How would SkyDrive call code on your local machine?
One way to do it is to first mock SkyDrive in your application -- that is, you don't call the real SkyDrive, just a service that you have running locally that acts as if it is SkyDrive. You can use that to develop and debug your application to some extent.
Then you can deploy your application to a test server on the Internet, so that SkyDrive can do the callback, and you can test it there and make the necessary modifications before you deploy to an actual production server.
I find a solution for my problem, I used pageKite to solve my problem. pagekite gave me an alternative to my localhost by mapping my localhost to a real domain. so I added that domain to my app in Microsoft and its working.

Is it possible to redirect a domain that's referenced in code before it gets there?

In code, we're referencing "athirdpartydomain.com"
Page.Response.Redirect("www.athirdpartydomain.com");
However, the owners of "athirdpartydomain.com" have decided to change their domain. This will involved a fairly considerable amount of work for us eventually, and they're letting the domain go completely.
We will of course change it in time, but I'm wondering if there's a quicker way to do this. Like changing something on the server to make sure all requests to "athirdpartydomain.com" all go to "theirnewdomain.com"
Considering you're using .NET, I can imagine you're also using IIS and, so, you can do this using IIS Redirects. NB, this will only work if you're hosting www.athirdpartydomain.com and have access to the IIS on that server.
You can learn how to do this here: http://support.microsoft.com/kb/313074
In .net you can't do that, but yes you can do that using cpanel of that domain.
You have to open that domain with admin login.
and you have to set "a name" or "a point" to particular server where you wants to redirect to site when some one browse the site this will redirect to particular site without load of that site.

Human readable URL in azure

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.

C# NET HTTP.SYS web server

I just need to create an extremely basic web server that will basically allow me to go to http://1.2.3.4:8080 and browse a list of files in C:\web or something.
I found this http://mikehadlow.blogspot.com/2006/07/playing-with-httpsys.html which looks perfect but I ran into a couple of questions.
1) When I replace the IP with * or + like the documentation says, I get access denied errors in system.dll. When I use localhost or my local IP it works fine. Why is this? I would like to potentially be able to bind it to a specific IP address on machines that have more than one.
2) I am probably missing something, but how do you specify the core directory where the files are that it is serving with this code?
re 1: because you dont have permissions to register this url. Use "http add urlacl2 to register permissions for your user (as admin) to make the binding. Example: http add urlacl url=http://+:8080/ user=DOMAIN\UserName
Re 2: You dont. THat is pretty much your code. Http.sys does not read from a file system - it is a driver. Your application must read the files and answer the request.
This might be a little overkill for what you want, but check out the aspNETserve web server project.
It is open source, so at the very least you can browse the code to get some ideas.
I know this does not help you with your code problems, but why re-invent the wheel! I think you should look at using IIS Express, as I think it could meet your needs nicely:
http://learn.iis.net/page.aspx/868/iis-express-overview/
IIS Express is a standalone executable that will provide all the functionality you need. It will also run on Windows XP and above.
Here's a Simple and Secure C# Webserver, offering Digest authentication without the need for Active Directory. Digest Auth is broken, but it is not practical to crack with passwords over 18 characters, anyway one can see how to make a webserver using C# and .NET HTTP.SYS which was the point of this question.
https://git.motes.camp/web/index.php?p=DigestAuthWebServer.NET-HTTPSYS.git&a=summary
clone url: https://git.motes.camp/DigestAuthWebServer.NET-HTTPSYS.git

Categories

Resources