asp.net - Local paths for the files are different from the paths on the server -


we have changed domain our staging website , turns out paths on server pointing old paths no longer valid. wondering if there have been better way paths @ begining did not have go through whole website fix paths. server paths hard-coded!!

example:

name1.staging.com/somepath/file.css

is changed

name2.staging.com/name3/somepath/file.css

so paths used like: /somepath/file.css

now need changed /name3/somepath/file.css

when you're writing asp.net application, important path need aware of following one:

    ~/ 

this return root of current application, whether pass response.redirect(), page.resolveurl() or use part of hyperlink in <asp:hyperlink /> tag. example:

<link href='<%= page.resolveurl("~/somepath/file.css") %>' rel='stylesheet' /> 

note works within code handled .net itself; other files, need ensure use relative paths. example if have following structure images , css:

/     /images         logo.gif     /css         main.css 

then reference logo using style:

{     background-image: url(../images/logo.gif); } 

Comments

Popular posts from this blog

c++ - Creating new partition disk winapi -

Android Prevent Bluetooth Pairing Dialog -

VBA function to include CDATA -