Click here to Skip to main content
15,891,633 members
Please Sign up or sign in to vote.
1.50/5 (4 votes)
See more:
if user hits the url indiaaclick.com then i want display url www.indiaaclick.com like this


thanks in advance
Posted
Comments
AspDotNetDev 21-Aug-12 3:41am    
Out of curiousity, are you trying to redirect from site.com to www.site.com? That is, are you trying to ensure the www subdomain gets prefixed to your site? There are some answerers below who seem to think you want something else.

This can typically be done at the registrar level. You can create a redirect that goes from site.com to www.site.com. The "www" is technically a subdomain. Google for instructions on how to do that with your registrar. For example, if you use GoDaddy, search "GoDaddy redirect to subdomain".

Also, if you have access to IIS, I think you can create a redirect from site.com to www.site.com.

If you really must do it from ASP.NET and you don't want to install a redirect module, you could modify your Global.asax and perform a conditional redirect (untested, so may not work exactly as shown):
VB.NET
Public Class Global_asax
    Inherits System.Web.HttpApplication
    Sub Application_BeginRequest(ByVal sender As Object, ByVal e As EventArgs)
        If Not Request.Url.Host.StartsWith("www.", StringComparison.InvariantCultureIgnoreCase) Then
            Dim builder As New UriBuilder(Request.Url)
            builder.Host = "www." + builder.Host
            Response.Redirect(builder.ToString())
        End If
    End Sub
End Class
 
Share this answer
 
Comments
ridoy 20-Aug-12 15:34pm    
much better answer..
Yogesh_Chavan 22-Aug-12 4:07am    
Thank you..
I assume,to input url text you have a textbox.So first get the text form textbox.
C#
string url=textbox1.Text;

Then in enter key press event for textbox1 try it..
C#
string finalString="www."+url;

then,
C#
textbox1.Text=finalString;
 
Share this answer
 
Comments
AspDotNetDev 20-Aug-12 14:50pm    
I presume the questioner is asking about performing a redirect, not actually displaying the altered URL in a textbox.
ridoy 20-Aug-12 15:01pm    
Ok,then he can use Respose.Redirect();here is a link which helps him..
http://msdn.microsoft.com/en-us/library/ms524309%28v=vs.90%29.aspx
AspDotNetDev 20-Aug-12 15:29pm    
The OP certainly could read the documentation, but I actually posted a specific answer that is likely to be more informative.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900