Sorry for the possibly misleading title of this post. Couln't really think of anything better at the moment.
Anyway, I have a site set up that allows users to search our customer database. I have a separate section of this site listed under a "reports" directory, which is used to generate billing reports, subscriber counts, etc. Apparently our users are confused about having to type in the reports folder on the url: http://maindomain/reports/.
I'm wondering if there is a way to create a new domain that points to that specific folder. In other words, users go to http://reportsdomain/ which would be an alias for http://maindomain/reports/. The solutions that I've considered are as follows:
Create a new site in IIS that points to the reports folder (which is a sub folder in the other site... seems like a bad practice since then two seperate IIS sites will be doing caching for that site, maintaining session/application state, etc).
Build a IIS module to do URL rewriting
Of those two options, I'd probably go with 2 before 1. Any other ways to do this that I'm not thinking of?
Thanks in advance for your help.
Respectfully,
Chris
Option 2 would be more ideal than the extra overhead of having two sites.
Using the Microsoft URL Rewrite Module for IIS 7.0
If you're okay with the user typing in the main URL and then being forwarded to the new URL, you just set up the http://maindomain site in IIS and then on the "Home Directory" page, set it to forward to http://maindomain/reports/.
While this isn't as clean as the URL re-writing option, it's painless to enable, and it seems like this might be the option you're looking for.
It would also be possible to handle this at the DNS level.
Related
I've seen a few questions asked about this, but haven't seen any the same as it (or solved)... So here it goes...
I have two ASP.Net MVC applications, one nested inside the other...
example.com
---sites
------example1.com
Both sites technically work fine, however all URLs for the example1.com domain are resolved to example1.com/sites/example1.com/.
I have the application roots setup correctly in IIS and am using #Html.ActionLink("Home", "Index", "Home") and #Url.Content("~/images/image.png") type references for links...
UPDATE
It looks like the host is showing the HttpRuntime.AppDomainAppVirtualPath is returning the wrong path, /sites/example1.com/ instead of just /.
Any ideas, things to try? Anything would be greatly appreciated.
Turned out to be that the host used some sort of a custom ISAPI extension to route domains to sub directories, and didn't create true application directories. So that explained all of the issues...
I'm using Sitefinity (6.1), ASP.Net and the 4.0 framework.
We have a sitefinty website already hosted on IIS as a website.
For licencing reasons we want to add a new site, also made with Sitefinity to the same
website as a subfolder.
Lets say website 1 is Foo and the new website is called Bar.
The problem is when I get or use the relative path form Bar, I really get the path from Foo.
So atm I am using a hack to get urls to work. I use the relative path and then insert Bar man ually.
e.g. page is called home. ~/home resolves to http://www.Foo.com/home. when it should be http://www.Foo.com/Bar/home, so I just add the Bar in manually atm.
There must be some way in ASP.Net or Sitefinity or MVC to say this is my page, give me the full url.
Has anyone has experence resolving urls for websites in another website?
Technically you're looking for an answer like this:
How do I get the full url of the page I am on in C#
But with regards to Sitefinity you're bound to run into trouble cause it has many 'under water' references to the site root. Take a look for instance in the backend under Administration >> Settings >> Advanced >> Virtual Paths.
So you're bound to run into some cross contamination and end up with two broken sites.
While I'm not for dodging licenses, here's a few suggestions:
They do allow unlimited subdomains.
Install 'bar' as an IIS application that way ~/ will resolve properly.
Change Administration >> Settings >> Advanced >> System >> SiteURL settings.
That last option will allow you to set the site-root (not iis/asp.net level but sitefinity level) at which point you could retrieve a proper url through Sitefinity API with page.GetFullUrl();
If anyone is wondering I found a simple solution that works in all environments.
string url = node.Url.Replace("~/", "./");
Where node is of type SiteMapNode (but you can get the url however you want of course).
That gives the correct path if there is a subfolder or not.
This string url = node.Url.Replace("~/", "./"); won't work if the page is not at the root level.
For example for this url: "xxxx://www.foo.com/sitename/sitefolder/sitepage" it will return "xxxx://www.foo.com/sitename/sitefolder/home", instead of "xxxx://www.foo.com/sitename/home"
I'm designing a site using ASPx and IIS, where clients can sign up and then offer services to their clients. For example:
if you go to http://www.mywebsite.com you can sign up for your mywebsite.com account as a business owner. When you sign up, you are given a Site ID (Example: AA1234).
http://www.mywebsite.com/AA1234
What I want to do is always include the Site ID in every url (Inbound and Outbound). The Site ID is stored in a session variable based on the initial incoming request.
Does anyone know of a good way to do this - or a different design that works better than this?
Thanks
Your question is nebulous at best. However...
Wouldn't this be what cookies are used for?
In particular, if your user is authenticated (this is generally achieved in asp.net with an auth cookie), then at the server, you would have tools at your disposal that allow you to recognize the user and provide a different experience according to whatever criteria you choose. Most likely, these details might be stored in a database.
Found the answer in this topic: http://www.tek-tips.com/viewthread.cfm?qid=1149673
The last response from BoulderBum is exactly what I needed.
Using the HTTP module I will take the /AA1234/ URL and point it to /Company/.
On the way out, I replace all instances of /Company/ with the site id again
I have to implement a single signon kind of solution on my website. Let's say my website is www.myweb.com and I want to allow the users to use this site who only come from a site www.sourceweb.com.
I thought URL Referrer would do but in IE may comes null.
See here
Please suggest me some alternate solution.
Thanks,
Gaurav
If you have access to www.sourceweb.com and can modify the source then a possible solution would be:
Create a webservice on www.myweb.com.
Create a link on www.sourceweb.com
When the link is clicked call the webservice to retrieve a unique id.
Redirect the user to www.myweb.com and provide the unique id in the querystring.
On www.myweb.com confirm that the unique id is valid and remove it/mark it as used.
There are many ways to skin a cat, one way in your case would be to set a cookie on the 2nd site, using a pixel gif (1x1 pixel small picture) embedded on a page of the main site. The 2nd site then can later allow access only when the cookie is already set.
To make this secure, you have to add a token to the pixel gif URL, containing a timestamp and signed using a HMAC or something similar establishing a shared secret with the other site. Then you only set the cookie when the timestamp is recent (less than a minute ago) and properly signed.
URL_REFERER is your best bet.
Keep in mind that like most HTTP headers, it is easy to forge and does not have to be provided.
The very short answer. Don't implement this yourself.
Security solutions should not be implemented but bought. The only exception being if you actually develops security solutions for other to buy of course.
Choose one of many available SSO solutions and go with that. We use Microsofts ADFS, though not perfect it gets the job done for us with very little maintance and the only real hazle is for our applications hosted on non-windows platforms like AIX.
There so many chance of screwing things up when you try to implement your own security solutions. If you disagree than just remember than anual contests are held to break the security systems of companies such as Apple,Microsoft,Mozilla and Goggle and most of the years some one takes home the price for breaking each of them.
We have multiple domains for one of our websites.
e.g. mydomain-uk.com and mydomain.co.uk
I have a handler which creates an XML sitemap and it uses HttpContext.Current.Request.Url.Host to retrieve the host site.
When my browser is on mydomain.co.uk/handler it retrieves mydomain-uk.com as the host
How can I ensure it always retrieves mydomain.co.uk ?
Is there a preference order configured somewhere on the server?
The host is get it from the URL on the request, and this is logical, you can not change this.
To solve this, create a static variable with your URL name, even better place it on your web.config, and just get this variable and not the Url.Host
Hope this help
Don't point all of your domains at the website. Have the extra domains perform a 301 redirect to the main domain name. This will also help resolve confusion by search engines when they try to resolve your site as to which site is the original source of your content, and will prevent inbound links from other websites from using a mixture of domains which will only exacerbate the problem.
Don't forget that HttpContext.Current.Request.Url.Host is simply going to return whatever HOST was requested at the time it happened. If the client requested something else, HttpContext.Current.Request will reflect this.