Click here to Skip to main content
15,741,011 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have a web page in which there is the options for downloading word documnet.
what i did , i create one tag from c# and set its href link to word document like bellow:
 StringBuilder sb = new StringBuilder();
sb.Append("http://www.mydomainName/doc1.doc' >");
Label l = new Label();
l.Text = sb.ToString();
so once page will render and end user if saw source page then he/she would be able to view that word document link but i dont want any end user to see my link
can u tell me how i can do this
Updated 10-Aug-11 21:17pm

This makes no sense at all. If you don't want them to see a link, don't render it. What other option is there ?

Also, your way of doing this is nuts. Why would you add a Label at random and fill it with HTML ? Why not put a literal in the right place on the form and populate that, or even a hyperlink ?
Share this answer
spydeehunk 11-Aug-11 3:26am    
this is demo code only that i thought. definetly first i would hyperlink on form first that will set from code behind. my main concern is to hide url that i want to secure because it is only avaible for registered user.
Christian Graus 11-Aug-11 3:39am    
I think that Dave has given you a correct answer. But there was no way anyone would get that as the obvious thing you were asking. The code you posted was all useless. You just needed to explain that you wanted to use a URL that was not the real URL for the file. But even that doesn't help, b.c either way, only your registered users will see the URL, the most you can hope to do, is hide your file structure from registered users to make them less able to guess the path to other files they may not be allowed to have. I'd use a HTTP Handler so that the URL passed in includes validation of the user's details, so that it would only serve files that user is allowed to have.
I have to agree with Christian - what you are doing does not make a lot of sense.

What are you trying to achieve, that you think this will help?
Share this answer
spydeehunk 11-Aug-11 3:33am    
this is demo code only that i thought. definetly first i would hyperlink on form first that will set from code behind. my main concern is to hide url that i want to secure because it is only avaible for registered user
OriginalGriff 11-Aug-11 3:39am    
If it is only supposed to be available to registered user, then the first thing to do is make sure you are using a proper login system that will not allow non-logged in users to access "private" pages - normally this is a case a putting them into a directory structure with the appropriate web.config settings - you know that already, I assume.
Then just check if the user is authorised and don't add it to the page if they aren't! Don't try to hide things on a page, because (as you also probably know) a quick right click followed by "view source" will give them any information they want, authorized or not...
spydeehunk 11-Aug-11 4:33am    
but these links are in database and so any user can copy that url and typed it in browser later n get that document even if i did the proper authentication and autherization
OriginalGriff 11-Aug-11 5:06am    
No, the whole idea of authentication is that the user must be logged in correctly in order to access the restricted pages.
And if the links are in the database, just don't server them up to a web page unless the user is correctly authorized.
spydeehunk 11-Aug-11 5:12am    
what if end user copy that url after sucessful login and type that URL in browser later.
I think you mean that you do not want the URL showing in the address bar, is that right?

If so there are several methods.

This method does an urlrewrite...

    <urlMappings enabled="true">
       <add url="~/home.aspx" mappedUrl="~/index.aspx?pid=01" />
       <add url="~/contacts.aspx" mappedUrl="~/index.aspx?pid=02" />
       <add url="~/sales.aspx" mappedUrl="~/index.aspx?pid=03" />

Obviously you need to adjust the pages and titles to your own needs.
Share this answer
Christian Graus 11-Aug-11 3:35am    
You could be right. IF that's the case, his actual question is clearly a nonsense.
Dalek Dave 11-Aug-11 3:36am    
I think it badly phrased, but it was the most sensible variation I could come up with.

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