MVC 客户端(Memo = "<img src="http://">")中检测到有潜在的危险的 Request.Form 值 的解决方案...

解释定义:
ASP.NET为了阻止跨站脚本攻击,会对向服务器端输入的HTML代码进行防御措施,在使用.NET MVC中,可以对validateinput属性设置,
但是,有时需要ASP.NET临时关闭这个检查机制,MVC中可以在Action上面添加一个特 性:[ValidateInput(false)]。

解决方案:

[ValidateInput(false)]

<httpRuntime requestValidationMode="2.0" />

在MVC 控制器上直接采用[ValidateInput(false)] 禁止验证信息就可以了,哪个控制器需要就在那儿添加这个属性;这样就可以保证数据的安全性了;

备注:有的时候 第一种方法会失效,具体原因不清楚(请大神指点);这个时候你可以采用第二种方法设置web配置文件<httpRuntime requestValidationMode="2.0" />

转载于:https://www.cnblogs.com/lizichao1991/p/5683779.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
const ViewRender = memo((props: ViewProps) => { const { pointData, pageData, width, dragStop, onDragStart, onResizeStop, preview } = props; const FixedData: Array<PointDataItem> = pointData.filter(e => e.item.type == 'Fixed') const nFixedData: Array<PointDataItem> = pointData.filter(e => e.item.type != 'Fixed') return ( (!preview ? ( <GridLayout cols={24} rowHeight={2} margin={[0, 0]} width={width} // @ts-expect-error onDragStop={debounce(dragStop, 500)} onDragStart={onDragStart} onResizeStop={onResizeStop} style={{ minHeight: '100vh', backgroundSize: '100%', backgroundRepeat: 'no-repeat', backgroundColor: pageData && pageData.bgColor, backgroundImage: pageData && pageData.bgImage ? `url(${pageData.bgImage[0].url})` : 'initial' }} > {pointData.map((value: PointDataItem) => ( <div key={value.id} data-grid={value.point} className={onDragStart && styles.dragItem} style={{ overflow: value.item.type == 'Fixed' ? 'visible' : 'hidden' }}> {value.item.type == 'Fixed' ? ( <div style={{ transform: `translateY(-${value.item.config.y}px)` }}> <DynamicEngine {...(value.item as any)} isTpl={false} /> </div> ) : ( <DynamicEngine {...(value.item as any)} isTpl={false} /> )} </div> ))} </GridLayout> ) : ( <> <GridLayout cols={24} rowHeight={2} margin={[0, 0]} width={width} style={{ minHeight: '100vh', backgroundSize: '100%', backgroundRepeat: 'no-repeat', backgroundColor: pageData && pageData.bgColor, backgroundImage: pageData && pageData.bgImage ? `url(${pageData.bgImage[0].url})` : 'initial' }}> {nFixedData.map((value: PointDataItem) => ( <div key={value.id} data-grid={value.point}> <DynamicEngine {...(value.item as any)} isTpl={false} /> </div> ))} </GridLayout> {FixedData.map((value: PointDataItem) => ( <div key={value.id} data-grid={value.point}> <DynamicEngine {...(value.item as any)} isTpl={false} /> </div> ))} </> )) ) })帮我优化这段代码
06-06
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值