one network two IIS web servers? will the switching occur? - c#

if
i have two IIS servers 5v on one network running winxp each hosting a separate site,
the navigation between the sites is related by using response.redirect("~/site2") when button is clicked on site1.
will this create any sort of chance of errors, like
you are connected to server1 which does not have this page!! or will the other IIS server read the browsers request and display the page?
it should but asking as i would like to know the downside of having two webservers on a single network.

If you literally use response.redirect("~/site2") then it will not navigate from one site to another. ~/site2 will be interpreted as, site2 folder in the current web application. You will need to use the absolute URL e.g. response.redirect("http://xpmachine2/site2")

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.

Two ASP.NET websites that shares one database

In general I need to know amount of visits on my website and access that data via API to have it everywhere.
For this I am trying to share EF database with 2 projects. One is simple Azure ASP.NET website with one controller which collects statistics of site visits. Second project is Azure mobile service that connects to the same database as website and provides access to that statistic via GET requests.
Locally I am getting such error:
Cannot attach file '...App_Data\aspnet-TargetrWebsite-20151001100420.mdf' as database 'aspnet-TargetrWebsite-20151001100420' because this database name is already attached with file '...\tagetr_statisticService\App_Data
So the problem that I have 2 web.config files with connection strings that points for 2 different files with the same database name.
How to get this work with one file on localhost and keep it worked on production as well?
Actually my target is know visits of page from everywhere. It is not required to use separated service for this. Just adding new authenticated controller which binds to Visits table on the same website solves the problem. Service removed then.
This could probably be done via Powershell script which sits on any machine.
Here's a good start where you can get back a list of IP addresses which are stored in an xml. You can then pull the xml into API quite easily I would believe. Also it should be quite easy to convert IP to url or location etc.
https://www.petri.com/powershell-problem-solver - Thanks to Jeff
Remember to watch your permissions!

Direct user to different page based on network connection

I am currently working on upgrading an existing asp.net web application. It is being hosted on our local web server and I would like to direct users to a different page if they are connecting locally.
Example: An employee connecting on our local network would be directed to page A. If someone on an outside network connects (presumably a customer) they would be directed to page B. Is this possible? Does the web server know if the connection is local or not? If so, I should be able to code for it. Any help or suggestions would be appreciated.
We've had an embarrassingly awful hack in place for this kind of situation for years. And while I'm sure there's a better way, what do do is look at the System.Web.HttpContext.Current.Request.UserHostAddress and if it matches a list we go to one page, otherwise we go another.

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.

live site and holding side by side until go live

I will shortly be going live with a new .net web application. It will be deployed to a load balanced environment over 5 servers.
Before go live there is a holding site on all the 5 servers to which the domain is currently pointing -> www.website.com
Prior to go live, I would like to deploy the new site to 5 servers and for the holding site to remain and for it to be what the public sees.
And when the time comes, I can put the new site live with a flick of a switch. I also want the new site to be on the servers so that I can test it prior to go live.
I am running in IIS7.
This is common practice I presume so what is the easiest way doing that above and achieve installing the new site on the servers will not affecting the holding site. The new site be accessible to me but the holding site be viewed by the general public. Any suggestions as to how this can be achieved?
You can create more than one website in IIS. I would create a new website on each machine with a temporary host header and then change it to the site URL when you want to go live. The load balancer may affect your decision on whether to deploy to another site using a host header, port, or some other identifier.

Categories

Resources