WebAPI帮助页面:禁用正式发布

编程入门 行业动态 更新时间:2024-10-22 21:28:43
本文介绍了WebAPI帮助页面:禁用正式发布的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我已经在VS 2010中使用较旧的WCF框架开发了许多内部REST接口。对于DEV和QA平台,它能够生成帮助页面的功能非常方便,但是对于生产版本而言,很容易禁用 web.config 文件中的以下帮助页面:

I have developed a number of internal REST interfaces using the older WCF framework in VS 2010. The ability for it to generate help pages was handy for DEV and QA platforms, but for a production release it was easy to disable the generation of these help pages in the web.config file:

<standardEndpoint name="" helpEnabled="false" automaticFormatSelectionEnabled="true"/>

我现在正在继续使用WebAPI框架(当前是VS 2012的版本1),但是关闭此功能似乎并不简单(即,在web.config文件中找不到有关如何执行此操作的任何信息)。

I am now moving on to use the WebAPI framework instead (currently version 1 on VS 2012), but it doesn't appear to be as trivial to turn this feature off (i.e. I can't find any information on how to do this in a web.config file).

当然,我可以继续在代码本身中手动执行此操作,但是肯定有更简单的方法;类似于WCF如何执行上述操作。我想使用web.config文件方法,因为我已经将web.release.config转换文件放置在其他设置中。

Certainly I can go ahead and do this by hand within the code itself, but surely there's an easier way; something akin to how WCF did it as described above. I'd like to use the web.config file approach since I already have the web.release.config transform files in place for other settings.

任何关于最佳做法的想法

Any thoughts on best practices on this would be appreciated.

推荐答案

相对于基于web.config的启用,Web API没有现成的支持或禁用帮助页面。

Web API doesn't have an out of box support with respect to web.config based enabling or disabling of helppage.

您可以考虑以下某些选项:

Some options you can consider:

  • 由于HelpPage是作为MVC区域安装的,因此在部署到生产环境时,您可以仅排除此 HelpPage 文件夹。

创建一个操作筛选器,该筛选器将返回404,如此处建议的那样:有条件地禁用ASP.NET MVC控制器

Create an action filter which returns 404 as suggested here: Conditionally disable ASP.NET MVC Controller

注意:对于上述情况,如果使用的是默认Web API模板,那么是的,您需要显示/不显示的其他步骤导航栏中的帮助链接。

NOTE: for the above cases, if you are using the default Web API template, then yeah you would need additional step of display/not display the Help link from the navigation bar.

更多推荐

WebAPI帮助页面:禁用正式发布

本文发布于:2023-10-11 23:19:42,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1483119.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:正式发布   页面   WebAPI

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!