Click here to Skip to main content
15,896,912 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have developed an aspx website where in i have a link to a page of that website given from code. the link is send to user on mail such that user can open a page by clicking on a link from their email..
here is the code of a link that is send on mail.

string leaveAddressForApproval = "http://localhost:5403/LeaveRequest.aspx?leaveRequestNo=" + txtLeaveNo.Text;

the address is send on a mail.. this code is during build form. but as i deploy it in client.. the localhost:5403 will have to be changed to their server ip.. is there a way to change this address without editing it from code at time of deploying?? is there a provision in visual studio that allows place to store this link and edit it during publish. google had told me to set it in web.config but i was not able to use it in iis... any help?? thanks in advance..
Posted

CSS
Hi
  It better to give server ip address in string leaveAddressForApproval = "http://localhost:5403/LeaveRequest.aspx?leaveRequestNo=" + txtLeaveNo.Text;

and then publish it and deploy in server machine,in server machine if it is url have ip address or locahost or machine name it work,but u r try to give url to other machine,so localhost:5403 definitively not work .localhost:5403  works only from server machine where u deploy.

Note: Leave application website deploy in server,so u need to give server ip address in a url link,better to chnage server ip address in url link like

string leaveAddressForApproval = "http://192.168.1.2/LeaveRequest.aspx?leaveRequestNo=" + txtLeaveNo.Text;

for eg 192.168.1.2 is server ip address.

And without web.config file cant work website,u can check in solution "web.config"

Regards
  Aravind
 
Share this answer
 
Comments
Codes DeCodes 5-Mar-14 1:52am    
thanks you for help ..
The simplest way is to use Virtual path instead of an absolute path. Or use Page.ResolveUrl method to specify the home path and add page url to it. Something like
C#
string leaveAddressForApproval = Page.ResolveUrl("~/") + "LeaveRequest.aspx?leaveRequestNo=" + txtLeaveNo.Text;


Still, if you need more flexibility, you got two options.
1) Get it from the database. But it's important to have it Cached so you don't need to make db call again and again. In our case, we have a table where we store such config related things in name value pair. We keep that table in Cache and use those values. So yes, that is an option.
2)Store it in your web.config. You can save it using Key-Value pair under ClientConfig > Paths node. In your release web.config add production url, in your local one use localhost url. You can access it by specifying
C#
ClientConfig.Paths["Key"];


Hope that helps!
 
Share this answer
 
v2
Comments
Codes DeCodes 4-Mar-14 2:23am    
thanks for the help.. i will try and let u know..
Ankur\m/ 4-Mar-14 2:30am    
Sure, let me know if that helps.

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