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.
Related
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!
I'm very new to web development but I will try to explain my question as best as I can.
I am making a basic admin panel program in C#. The admin panel will pass the data to android SQLite database using XML files, so XML file will be generated whenever admin updates data, and then it'll send the data to mobile phone.
Developing is all done but I need to host the admin panel in order to give XML links to my mobile app developer so she can create XML parser class or something. (please bear with me, I'm very new to programming). Anyway, I have no idea how to host it!
I've done some Googling but they all saying I need to buy domain name. I need to host it without buying domain.
Hope that's clear. Thanks in advance.
If you are looking for a very good hosting and you don't mind about the domain name definitely try microsoft azure it is very quality server and free when you don't want to use your domain name. I mean your address would be yourdomain.microsoftazure.com instead of yourdomain.com. It is always free and you can have an sql server database free for first year. however you should put a credit card number that only used for identification and microsoft never charge you for that.
See the site below:
https://azure.microsoft.com/
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.
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")
Are there any prebuilt modules for this? Is there an event thats called everytime a page is loaded? I'm just trying to secure one of my more important admin sections.
As blowdart said, simple IP Address logging is handled by IIS already. Simply right-click on the Website in Internet Information Services (IIS) Manager tool, go to the Web Site tab, and check the Enable Logging box. You can customize what information is logged also.
If you want to restrict the site or even a folder of the site to specific IP's, just go to the IIS Site or Folder properties that you want to protect in the IIS Manager, right click and select Properties. Choose the Directory Security tab. In the middle you should see the "IP Addresses and domain name restrictions. This will be where you can setup which IP's to block or allow.
If you want to do this programatically in the code-behind of ASP.Net, you could use the page preinit event.
A little more information please; do you want to log IPs or lock access via IP? Both those functions are built into IIS rather than ASP.NET; so are you looking for how to limit access via IP programatically?
You can use the following to get a user's IP address:
Request.ServerVariables["REMOTE_ADDR"]
Once you have the IP you will have to write something custom to log it or block by IP. There isn't something built in to asp.net to do this for you.
Is there an event that's called everytime a page is loaded?
Page_Load might be what you're looking for.
However, and I'm really not trying to be mean here, if you don't know that, you probably shouldn't be trying to secure the app. You're just not experienced enough in .Net
I'm sure you're great at what you do, in whatever platform you're experienced in. But .Net WebForms isn't your forte. This is one of those times when you should back off and let someone else handle it.