AXForum  
Вернуться   AXForum > Microsoft Dynamics CRM > Dynamics CRM: Blogs
All
Забыли пароль?
Зарегистрироваться Правила Справка Пользователи Сообщения за день Поиск Все разделы прочитаны

 
 
Опции темы Поиск в этой теме Опции просмотра
Старый 22.09.2009, 17:05   #1  
Blog bot is offline
Blog bot
Участник
 
25,643 / 848 (80) +++++++
Регистрация: 28.10.2006
Dynamics CRM Tools: SiteMap, IFD/OnPremise and relative URLs
Источник: http://mscrmtools.blogspot.com/2009/...tive-urls.html
==============

I don’t know if you've already faced this problem: When you develop a web page that you want displayed via the SiteMap Navigation, the URLs called are different depending whether you are in OnPremise or IFD mode.

In IFD, you get a URL like http://organization_name.domain.extension/ISV/default.aspx

In OnPremise, it will look like
http://organization_name.domain.extension/organization_name/ISV/default.aspx

I assume that you use the same URL to access both Dynamics CRM authentication mode.


Now, if you want to use relative URLs to load images, scripts or other (which are also contained in the ISV folder), you're facing a problem: how to use relative URLs to be valid for both IFD and OnPremise mode?

The simplest answer, which is often found on the forums, is: Use absolute URLs.

Certainly, but this is not very clean to use hard coded server names.

So I propose you my method. Maybe not the best but it does the job (even if, as we shall see, it still uses absolute URL).

In the code behind your ASP.Net page, create a new string property called BaseUrl.

In the Get accessor, write the following code:

public string BaseUrl
{
get
{
string baseUrl = string.Format("{0}://{1}",
Request.IsSecureConnection ? "https" : "http",
Request.Url.Host);

return baseUrl;
}
}




Then in the HTML content of your website, you can use the wherever you want to reference relative URLs.


For example:




Well, it’s right, you still have an absolute URL in the source code of the page. But at least you do not have to worry about changing environments and authentication mode.

Note: If you need relative URLs on your scripts, you can replace the ".js" file by an ".aspx" file and perform the same manipulation as above.






Источник: http://mscrmtools.blogspot.com/2009/...tive-urls.html
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору.
 

Опции темы Поиск в этой теме
Поиск в этой теме:

Расширенный поиск
Опции просмотра

Ваши права в разделе
Вы не можете создавать новые темы
Вы не можете отвечать в темах
Вы не можете прикреплять вложения
Вы не можете редактировать свои сообщения

BB коды Вкл.
Смайлы Вкл.
[IMG] код Вкл.
HTML код Выкл.
Быстрый переход

Рейтинг@Mail.ru
Часовой пояс GMT +3, время: 13:51.