Transform Webconfig任务出乎意料的失败 - 访问被拒绝
我已经在Azure托管的Net6网站中添加了一个Web.config文件。 web.config文件应像在此处一样转换:< Web-config-transrymations“ rel =“ nofollow noreferrer”> https://learn.microsoft.com/en-us/aspnet/web-forms/web-forms/overview/deployment/visual-studio-studio-studio-web-deployment/web-config-transformations )
我正在使用Web配置来定义IIS的重定向规则。 (将请求重定向到一个域。)
现在,当我尝试发布网站时,我收到一个错误,上面写着“ TrasnformWebConfig任务意外失败”。搜索原因后,我发现这是由“ out”目录beeing heolly读取中的web.config文件引起的。
现在,我确实在寻找这个问题的答案,并且经常给出的一个答案是,应该完全禁用“ webconfigtransforms”。 (例如:” /a>)
但是,当我这样做时,放置在服务器上的最终web.config文件仅包含“我的”零件,而不是核心网站完全运行的零件。 (Visual Studio(?)生成并发布该网站所需的“默认”部分。如果缺少这些部分,则该站点是无法使用的。)因此,,完全禁用转换似乎不是一个选择。
经过更多的摆弄后,我发现如果IA查看我的Web.config文件,问题就会出现。如果从源控件中检查了一下(我在网上使用TFS),则它在OUT目录和转换工作中也不是读取的。
因此,我“快速”的解决方法是在发布前查看web.config。我认为这不是必需的。那么,如何在不查看文件的情况下进行此工作?
I have added a web.config file to my net6 website which is hosted on azure. The web.config file should be transformed like documented here: ( https://learn.microsoft.com/en-us/aspnet/web-forms/overview/deployment/visual-studio-web-deployment/web-config-transformations )
i'm using the web config in order to define a redirect rule for iis. (redirecting request to one domain to another domain.)
Now, when i try to publish the website, i receive an error that says "TrasnformWebConfig task failed unexpectedly". After searching for the cause i found this is caused by the web.config file in the "out" directory beeing read-only.
Now, i did look for answers to this problem and the one answer given quite often is, one should disable "WebConfigTransforms" altogether. (e.g.: "The "TransformWebConfig" task failed unexpectedly" on dotnet publish)
However, when i do this, the final web.config file placed on the server only contains "my" parts, not the parts that are needed for a core website to run at all. (visual studio (?) generates and publishes the 'default' parts that are needed for the site to function at all. if these parts are missing, the site is unuseable.) So, disabling the transformation altogether does not seem to be an option.
After some more fiddling, i found that the problem goes aways if i a check out my web.config file. If it is checked out from source control (i use tfs on vs online), it's also not read-only in the out directory and the transform works.
So i "quick" workaround is to check out the web.config before publishing. I don't think this should be necessary though. So how do i make this work without checking out the file?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我看到您已经尝试禁用
webconfigtransforms
,但是,您可以尝试以下解决方法来解决错误:解决方案1:
删除
csproj中的以下行
文件。解决方案2:
有一个与大写有关的错误。在
csproj
文件中,尝试更改inprocess
使用小写解决方案3:
在
web.config
中,文件代码线:参考:
the“ transformwebconfig” AspnetCoreModuleHostingModel属性的价值是
I see that you have already tried disabling
WebConfigTransforms
, However, you can try the below workarounds to resolve the error :Solution 1 :
Delete the following line in your
csproj
file.Solution 2:
There is a bug related to UpperCases. In
csproj
file , try changingInProcess
with lowercaseSolution 3:
In your
web.config
, file try adding this line of code:Reference :
The "TransformWebConfig" task failed unexpectedly - System.Exception: The acceptable value for AspNetCoreModuleHostingModel property is either