Allow user when registered to browse to username.host.com - iis-7.5

I am using Asp.net MVC3 and C# and IIS 7.5. I want that once user is registered he can browse my site using username.host.com and this username should be available to me in my URL so I can show the data related to that particular username only. All the logic is the same for all users. I don't want to do any fancy thing like if user1.host.com is entered then I want to redirect to a separate controller and action etc. All the application logic is the same for all users. I just want to change the way the url is shown in the browser.
Also, if possible I want this to work on localhost also in IIS/Cassini.
Eg: If I browse to jaggu.localhost:19883. It should send me to localhost:19883/Home/index/Jaggu (because by default Home is the controller and index is the method)
I am completely clueless on how to achieve this. Any help would be appreciated.

You may need a star A record, like *.host.com that points to your host.com site.
On your default page (or elsewhere via something like an IHttpModule) reroute the request to where you want the registered user to land.
Google: URL Rewriting for more information.

Related

custom domain name per customer single page application

I want to give my customer the ability to create their own todos list app/web.
So, I thought they could register to my application, for instance:
http://mytodos-app.com/signup and provide all preferences such as theme, title, name...
Now i could use the url/router ability to get some unique identifier from the url and use the same app, but fetch data for each customer.
i.e: http://mytodos-app.com/todos/:someuniqeid
1) is it sounds ok? or are there better strategies for this scenario?
2) if it's ok, If I want to give them the ability to configure their own domain (like in shopify you get some dynamic domain yourname.shopify.com).
So, what is the most popular/professional way to do it? I want it to be easy to the customer. any suggestions?
Other than the "cool factor", there is no benefit to using actual customized sub-domains.
You can synthesize the behavior by:
In DNS, set up a wildcard CNAME entry for *.DOMAIN.com to point to www.DOMAIN.com, be sure to buy a matching wildcard ssl/tls certificate.
Configure the web server to respond to all hostnames.
After user registration. SANITIZE the username(or whatever identifier) value.
Set an authorization cookie with the domain=DOMAIN.com option to force it not to
be a host cookie.
Redirect to username.DOMAIN.com. Same server different name.
Check the cookie in the route to serve the correct pages. Just like
you would with any login.
If there is no cookie, use the host information to populate the
username portion of the login page, or display public todos?
Make sure any Javascript scripts hosted on the site and all internal links are loaded by relative addressing.
The technique is much safer than actually creating real subdomains.

How to make a single url host multiple websites?

I've noticed many sites use some strategy to host their two sites for pc and mobile users on only one url. For example, https://read.douban.com , its pc site and mobile site uses one url, how does this happen? Note I'm not asking the responsive design because its mobile site does use responsive design itself. And I don't think it is a nginx redirect because the urls are the same. There is one link on the mobile site to switch between the two sites.
How does they make a single url host multiple websites? And how to switch between them?
Thanks.
I guess there are many ways. One way I know, is with Struts: Each request is going through Java logic and then an JSP page is sent to the user {This is a very simplified way to look at Struts}.
So, in this case a request comes from a mobile browser - will get a JSP made for mobile. A request from a PC will get a JSP for PC. The URL can stay the same.
If you separate the user request then you can hosting a single url to multiple websites?
So First detect the user request.
NB: I only consider the incoming user request is from PC or other devices(Phone, Tab, etc..)
STEP 01: request is from PC
// return negative value if the request is from PC
var myNavigator = navigator.appVersion.indexOf("Mobile");
So, based on myNavigator value, we make separate sites.
Tnx, Happy coding!

Preferred way to direct user's domain names to my web app?

Background context: ASP.NET / IIS (not sure if it matters)
I have a web app at example.com, and a user of my app gets his own content page at an address like example.com/abc-trinkets. I would like to offer the user the ability to point his own registered domain at my web app so his content is accessed at abctrinkets.com. Initially looking on the order of 10-100 users with custom domains.
Ideally, I would like my user to just have a single hostname or IP address that he needs to know to configure properly with his registrar, and if I change the setup of my servers (different host, change addresses, load balancing, etc.) the user will not have to change his settings.
I have no trouble handling the requests once they hit my web app, but I am looking for input on the best way to set the routing up so requests actually come to my app/server. I would like a "catch-all" type of behavior that does not require me to individually configure anything for each domain a user might point to me.
I assume I will need some kind of layer between the address I give my user and my actual server ... is this like a managed DNS service or some other type of nameserver thing I would set up with my host? Is this something simple that should already be handled by a few simple settings on my webserver? I worry that I am making this more complicated than it needs to be.
Write a script that examines the Host header in the request. In your example, if it's abctrinkets.com, then you'd either redirect or forward the request to /abc-trinkets. You'd still need a database or something for mapping the domain names to the URLs; if you're going to allow arbitrary domain names for each user account, then there's no possible way to avoid that.

Static Main Page (login page) on Drupal Install

I am starting to create a site that uses Drupal. One of my requirements is that nobody will see any "real" content until they log in. The home page will basically be a static page with a logo, some basic "this is what the site does" copy, and then a login form. If you don't login, you can then only see some other static pages (faq, legal, privacy, etc...) but you can't use the actual site. Think Facebook's login page, basically just fluff with a login form.
From searching around, I have found 3 different methods for this:
Create a page that is basically separate from the Drupal installation, but then when the form submits, check it against the Drupal DB and then proceed if logged in successfully. This would be done with Apache, maybe an .htaccess file directive to change the first served page.
Use the Front Page extension. I haven't looked at this too extensively, has anyone used it? Pros/Cons?
Somehow finagle the default Druapl "Home Page" functionality to allow this to happen. I would rather not have to do this, unless someone knows that there is an easy way to do this.
One of my requirements is that nobody will see any "real" content until they log in.
There is a permission that users need have in order to access content on Drupal (access content); if anonymous users don't have that permission, then they would not be able to see any content.
Using the module you reported, you can create a different home page for anonymous users.
Solution #1 is not the ideal one as it requires more work for something that can be obtained from inside Drupal. Take in mind that the correct way to access Drupal DB is to use the DB API Drupal comes with.

Sharepoint: Redirect user to default site

Is it possible to set a default site for a group of users in Sharepoint and have the main default page redirect them to the sub site?
I don't know an out of the box feature which could do this, but you could write a small WebPart which does the redirect depending on the user who visits the site. Shouldn't be to difficult.
The configuration could either be stored in the web part itself or within a list. To speedup the whole redirect process you should cache the redirect information when it was read from the configuration.
That's the way I would do this.
Don't forget to think about a way which let you access and edit the page with the redirect web part without getting redirected.

Resources