asp.net-web-api - Asp.net WebApi (MVC 5) 从客户端检测到潜在危险的 Request.QueryString 值
问题描述
我的发送模型
public class Mymodel{
[AllowHtml]
public string Body { get; set; }
public int ResponderId { get; set; }
}
从角度客户端发送
let params = new HttpParams().append('model', JSON.stringify(mymodel));
return this.http.post(`url`, data, { params: params });
和服务器
var httpRequest = HttpContext.Current.Request;
var model = httpRequest.Params["model"]?.ToString();
if (model == null) return null;
return JsonConvert.DeserializeObject<Mymodel>(model);
当body属性有html元素时出错
A potentially dangerous Request.QueryString value was detected from the client
当正文具有 html 元素字符串但不起作用时,我使用此代码。
httpRequest.Unvalidated[parameterName]?.ToString();
解决方案
推荐阅读
- java - 在 android Studio 钢琴练习中使用 SoundPool 播放并行声音的问题
- jquery - 使用 Laravel Carbon 将日期保存为 MySQL 格式
- python-3.x - 如何修复“将数据从 flask-socketio 事件处理程序传递到 Flask-SQLAlchemy”
- python - 用包含字符串的变量替换函数属性
- python - 从多个 URL 提取原始文本
- ios - Nativescript 插件在 Podfile 中指定 Pod 版本
- c# - 在使用arduino通过端口显示增量后,我如何清洁标签?
- python - 格式漂亮的 numpy JSON 编码器
- php - 从 PHP 中的字符串中获取特定数据
- java - setOnClickListener(android.view.View$OnClickListener)' 在空对象引用上