<bdo id='T3fw4'></bdo><ul id='T3fw4'></ul>

    <i id='T3fw4'><tr id='T3fw4'><dt id='T3fw4'><q id='T3fw4'><span id='T3fw4'><b id='T3fw4'><form id='T3fw4'><ins id='T3fw4'></ins><ul id='T3fw4'></ul><sub id='T3fw4'></sub></form><legend id='T3fw4'></legend><bdo id='T3fw4'><pre id='T3fw4'><center id='T3fw4'></center></pre></bdo></b><th id='T3fw4'></th></span></q></dt></tr></i><div id='T3fw4'><tfoot id='T3fw4'></tfoot><dl id='T3fw4'><fieldset id='T3fw4'></fieldset></dl></div>

    1. <tfoot id='T3fw4'></tfoot>

    2. <small id='T3fw4'></small><noframes id='T3fw4'>

      <legend id='T3fw4'><style id='T3fw4'><dir id='T3fw4'><q id='T3fw4'></q></dir></style></legend>
    3. Yii2框架如何处理CSRF验证?

      时间:2023-10-16
          <bdo id='2ie7g'></bdo><ul id='2ie7g'></ul>

          1. <small id='2ie7g'></small><noframes id='2ie7g'>

              1. <i id='2ie7g'><tr id='2ie7g'><dt id='2ie7g'><q id='2ie7g'><span id='2ie7g'><b id='2ie7g'><form id='2ie7g'><ins id='2ie7g'></ins><ul id='2ie7g'></ul><sub id='2ie7g'></sub></form><legend id='2ie7g'></legend><bdo id='2ie7g'><pre id='2ie7g'><center id='2ie7g'></center></pre></bdo></b><th id='2ie7g'></th></span></q></dt></tr></i><div id='2ie7g'><tfoot id='2ie7g'></tfoot><dl id='2ie7g'><fieldset id='2ie7g'></fieldset></dl></div>
              2. <legend id='2ie7g'><style id='2ie7g'><dir id='2ie7g'><q id='2ie7g'></q></dir></style></legend>
                  <tbody id='2ie7g'></tbody>
                <tfoot id='2ie7g'></tfoot>
                本文介绍了Yii2框架如何处理CSRF验证?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我在 yii2 中遇到 CSRF 验证问题.验证与 gii 生成的默认表单一起工作正常,但是当我使用 html 标签编辑表单时,表单提交会引发错误的请求错误.我已禁用 csrf 验证以隐藏错误,但我想将其用于应用程序和数据验证的安全性.

                I'm having problem with CSRF Validation in yii2. The validation works fine with the default form generated by the gii but when I edit the form with html tags then the form submission throws a bad request error. I have disabled csrf validation to hide the error but I want to use this for the security of the application and data validation.

                有没有办法解决这个错误,或者有没有办法配置它在这种情况下正常工作?

                Is there any way of solving this error or is there a way of configuring it to work correctly in this scenario?

                推荐答案

                我猜,你的 html 表单没有隐藏的 _csrf 字段,它是由标准 Yii2 小部件自动生成的.

                I guess, your html form doesn't have hidden _csrf field, which is automatically generated by standard Yii2 widgets.

                所以你的自定义表单的最小代码可能是这样的:

                So the minimum code of your custom form might be like this:

                <form method="post">
                    <input type="hidden" name="<?= Yii::$app->request->csrfParam; ?>" value="<?= Yii::$app->request->csrfToken; ?>" />
                    <button type="submit"> Save </button>
                </form>
                

                这篇关于Yii2框架如何处理CSRF验证?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:yii2:在一行中连接多个值的下拉列表 下一篇:如何在 YII2 中创建模块

                相关文章

              3. <small id='UeN7Y'></small><noframes id='UeN7Y'>

              4. <legend id='UeN7Y'><style id='UeN7Y'><dir id='UeN7Y'><q id='UeN7Y'></q></dir></style></legend>
              5. <i id='UeN7Y'><tr id='UeN7Y'><dt id='UeN7Y'><q id='UeN7Y'><span id='UeN7Y'><b id='UeN7Y'><form id='UeN7Y'><ins id='UeN7Y'></ins><ul id='UeN7Y'></ul><sub id='UeN7Y'></sub></form><legend id='UeN7Y'></legend><bdo id='UeN7Y'><pre id='UeN7Y'><center id='UeN7Y'></center></pre></bdo></b><th id='UeN7Y'></th></span></q></dt></tr></i><div id='UeN7Y'><tfoot id='UeN7Y'></tfoot><dl id='UeN7Y'><fieldset id='UeN7Y'></fieldset></dl></div>

                    • <bdo id='UeN7Y'></bdo><ul id='UeN7Y'></ul>
                    <tfoot id='UeN7Y'></tfoot>