我正在尝试在Azure Web App的本地测试和云测试之间进行无缝移动。以下是我的Web.Config文件的片段。
<appSettings>
<add key="ida:ClientId" value="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" />
... more items ...
</appSettings>
ClientId
的值对应于&#34;应用注册&#34; Azure Active Directory实例中的对象。当我点击该对象并导航到设置 - &gt;回复网址,条目为https://localhost:xxxxx/
。
我的问题是:当我将Azure Web App发布到云时,我被重定向到上面的localhost URL。但是,如果我添加另一个https://mywebappname.mydomain.com
的回复网址条目,那么当我尝试在本地进行测试时,我会被重定向到网址而不是本地主机网址。
我想要一种无缝的本地和云测试方法:在本地和云端测试时,我希望重定向到正确的URL。为了实现这个目标,我缺少哪些配置?
----更新----
当我在Visual Studio 2017中右键单击Web应用程序项目然后单击“属性”时,我将进入此屏幕。以下是我设置的一些其他属性,这些属性重定向到https://localhost:xxxxx/
。我需要更改吗?如果是这样,我如何在项目的属性中同时拥有两个重定向URL?
答案 0 :(得分:1)
我最终通过使用Web.config转换语法解决了这个问题(请参阅原始帖子评论中的Stephen Muecke的链接)。
在与Web.config
相同的目录中,我添加了Web.Release.config
。现在,如果在Visual Studio中我选择“Release”构建,那么Web.Release.config
转换配置文件将用于将Web.config
文件的“ida:RedirectUri”键替换为转换配置文件中的值。
以下是Web.Release.config
<?xml version="1.0"?>
<!-- For more information on using Web.config transformation visit https://go.microsoft.com/fwlink/?LinkId=301874 -->
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<appSettings>
<add key="ida:RedirectUri" value="https://<mywebappname>.<mywebappdomain>.com/" xdt:Transform="Replace" />
</appSettings>
</configuration>
这是一个来自非常大的Web.config
<?xml version="1.0"?>
<!-- For more information on using Web.config transformation visit https://go.microsoft.com/fwlink/?LinkId=301874 -->
...
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
...
<appSettings>
<add key="ida:RedirectUri" value="https://localhost:xxxxx/" xdt:Transform="Replace" />
...
</appSettings>
...
</configuration>
这样,重定向到localhost
是默认设置。