简体   繁体   中英

CRM 2011 external content with relative URL

In CRM 4.0 we could place dynamic content (aspx) in the ISV-folder in CRM, creating separate applications but with security and relative URLs to CRM, so for example a custom 360 view of account could be linked in an iframe using a relative URL along the lines of

/ISV/CrmMvcApp/Account.aspx/Overview?id=....

In CRM 2011 usage of the ISV folder is deprecated and Microsoft has some guidelines on how to transition into doing this in supported manner ( MSDN gg309571: Upgrade Code in the ISV folder to Microsoft Dynamics CRM 2011 ). They say:

For scenarios that will not be satisfied by the Web resources feature, create your Web application in its own application pool with its own web.config.

The way I am reading this (coupled with the guidelines on supported/unsupported) is that we need a separate web site in IIS with its own binding as you are not allowed to add virtual directories etc. under the standard CRM app. This is unfortunate and does not allow relative paths/URLs in customizations and sitemap. This is troublesome especially when exporting and importing solutions from DEV, TEST and/or PROD.

  • Are my assumptions wrong?
  • Can we somehow have relative paths?
  • Have anyone else found a pragmatic and easy approach to having external content without doing the sitemap and customization changes for each environment?

EDIT : Confirmed with other sources that my understanding of the guidelines are correct, as this is also listed in the list of unsupported changes. Virtual folders and web apps are to be kept totally separated from the default CRM web site.

Creating an Internet Information Services (IIS) application inside the Microsoft Dynamics CRM website for any VDir and specifically within the ISV folder is not supported.

MSDN gg328350: Unsupported Customizations

If you primarily need to access CRM data/records, take a look at using a jScript web resources. You can do "most" CRUD operations using the REST OData services. If you use JQuery to parse the JSON it's very productive.

I have found a solution much like the javascript redirect, without the need for client execution and only configuring the environment details (servername, port) once. Additional logic can easily be added.

The solution creates a dependency into the customizations, but not an environment one like and can be used for unmanaged and managed solutions.

The solution was to place a file Redirect.aspx in the ISV folder. The code does not in any way interact with CRM and falls within the supported guidelines, however the solution is not future proof as the ISV folder is deprecated by Microsoft.

Redirect.aspx will automatically pass along any parameter passed, so will work with or without the entity identifiers and so on.

Usage:

  • Place the file in the ISV folder on the CRM app server
  • Change the server name and port to match the current environment (must be done for each environment)
  • In customizations, for example for an iframe, use the following as a source:

     /ISV/Redirect.aspx?redirect=http://SERVERREPLACE/CustomMvcApp/SomeControllerAction 

Here is the content of Redirect.aspx

<%@ Page Language="C#" %>    
<html>
<script runat="server">
  protected override void OnLoad(EventArgs e)
  {
      // must be customized for each environment
      const string ServerBaseName = "appserver1:60001"; 
      const string UrlParameterName = "redirect";
      const string ReplacePattern = "SERVERREPLACE";

      var parameterUrl = Request.Params[UrlParameterName].Replace(ReplacePattern, ServerBaseName);

      var queryStringBuilder = new StringBuilder();

      foreach (var key in Request.QueryString.AllKeys)
      {
          if (key == UrlParameterName)
          {
              continue;
          }

          queryStringBuilder.Append(!(queryStringBuilder.Length > 0) ? "?" : "&");
          queryStringBuilder.Append(key + "=" + Request.QueryString[key]);
      }

      var completeRedirectString = parameterUrl + queryStringBuilder;

      Response.Redirect(completeRedirectString);
  }   
</script>
<head>
    <title>Redirecting</title>
</head>
</html>

根据您的问题,不是“相对网址”,但我使用的解决方案是在配置实体中存储“存根”或“根”网址,并在运行时在JScript中读取这些记录,以确定自定义链接的完全限定目标。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM