ASP.NET MVC RequireHttps仅在生产中(ASP.NET MVC RequireHttps in Production Only)
我想使用RequireHttpsAttribute来阻止不安全的HTTP请求发送到action方法。
C#
[RequireHttps] //apply to all actions in controller public class SomeController { [RequireHttps] //apply to this action only public ActionResult SomeAction() { ... } }
VB
<RequireHttps()> _ Public Class SomeController <RequireHttps()> _ Public Function SomeAction() As ActionResult ... End Function End Class
不幸的是,ASP.NET开发服务器不支持HTTPS。
发布到生产环境时,如何使ASP.NET MVC应用程序使用RequireHttps,而不是在ASP.NET开发服务器上的开发工作站上运行?
I want to use the RequireHttpsAttribute to prevent unsecured HTTP requests from being sent to an action method.
C#
[RequireHttps] //apply to all actions in controller public class SomeController { [RequireHttps] //apply to this action only public ActionResult SomeAction() { ... } }
VB
<RequireHttps()> _ Public Class SomeController <RequireHttps()> _ Public Function SomeAction() As ActionResult ... End Function End Class
Unfortunately, ASP.NET Development Server doesn't support HTTPS.
How can I make my ASP.NET MVC application use RequireHttps when published to the production environment, but not when run on my development workstation on the ASP.NET Development Server?
原文:https://stackoverflow.com/questions/1639707
最满意答案
创建Sequelize对象时,将
false
传递给logging
参数:var sequelize = new Sequelize('database', 'username', 'password', { // disable logging; default: console.log logging: false });
有关更多选项,请查看文档 。
When you create your Sequelize object, pass
false
to thelogging
parameter:var sequelize = new Sequelize('database', 'username', 'password', { // disable logging; default: console.log logging: false });
For more options, check the docs.
相关问答
更多-
User.hasMany(Post, {foreignKey: 'user_id'}) Post.belongsTo(User, {foreignKey: 'user_id'}) Post.find({ where: { ...}, include: [User]}) 哪个会给你 SELECT `posts`.*, `users`.`username` AS `users.username`, `users`.`email` AS `users.email`, `users`.`passwo ...
-
结束查询失败(Sequelize Query Failing)[2022-05-19]
查询将加入warehouse_reservation_info,而传递给DefaultModelConfig的名称是warehouse_reservationinfo。 表名之间不匹配。 The query is joining on warehouse_reservation_info whereas the name passed to DefaultModelConfig is warehouse_reservationinfo. There is a mismatch between table n ... -
在执行查询时防止Sequelize输出到控制台?(Prevent Sequelize from outputting SQL to the console on execution of query?)[2023-02-10]
创建Sequelize对象时,将false传递给logging参数: var sequelize = new Sequelize('database', 'username', 'password', { // disable logging; default: console.log logging: false }); 有关更多选项,请查看文档 。 When you create your Sequelize object, pass false to the logging parame ... -
你尝试使用sepparate xml配置吗? http://nhibernate.info/doc/howto/various/configure-log4net-for-use-with-nhibernate.html Did you try using a sepparate xml config? http://nhibernate.info/doc/howto/various/configure-log4net-for-use-with-nhibernate.html
-
需要attributes:['NameOfColumn1','NameOfColumn2', etc.] 例如,在我的情况下: User.find({ attributes: ['Name'], where: { Name: 'matt' } }) 只会考虑查询中的列Name 。 活泉。 此外,除非模型定义中存在timestamps: false ,否则模型将包含这些值,并且在查询表是否未相应地同步时可能会抛出错误。 例如,在我的 ...
-
你必须以两种方式定义关系。 UserChatRoom有一个ChatRoom,ChatRoom属于UserChatRoom。 此外,您的关系应放在每个模型中,而不是放在索引中。 module.exports = function(sequelize, DataType){ var ChatRoom = sequelize.define("ChatRoom",{ idChatUser: { type: DataType.INTEGER, a ...
-
为什么Sequelize发布“SHOW INDEX FROM`table`”?(Why Sequelize issues “SHOW INDEX FROM `table`”?)[2021-11-07]
Sequelize使用SHOW INDEX FROM的原因是为了避免第二次将现有索引添加到模型表中。 第二次添加现有索引会导致错误。 Sequelize目前还不够“聪明”,无法理解你没有定义任何索引。 无论如何它会检查表。 在您的方案中,由于您强制同步,因此没有任何区别。 这意味着表总是被删除并新创建。 添加新索引时,不会有任何现有索引。 想象一下,你会指定一个像这样的索引的模型: sequelize.define('user', {}, { indexes: [ // Create a u ... -
在这种情况下,您需要在这三个模型上执行急切加载 User.all({ attributes: ['username'], // return only 'username' column from 'users' table include: [ { model: Player, // eager load players on players.userId = users.id attributes: ['points'], ...
-
您已在belongsTo关联中定义了alias ,因此您还需要在查询时在include属性中include别名。 此外, channel.name列值也应包含在查询的include对象中。 channelUsersM.findAll({ attributes: ['username'], where: { usertype: this.userType }, include: [ { model: channelM, ...
-
这是sequelize的预期行为,仅选择您已定义的列。 如果要使用sequelize选择所有列,则必须在模型中定义它们。 This is expected behavior of sequelize selecting only the columns which you have defined. If you want to select all of the columns using sequelize you must define them in your model.