我的网站每天大约20次提出这个异常,通常表单工作正常,但有些情况发生这个问题,我不知道为什么这么随机.
这是elmah记录的异常
500 HttpAntiForgery所需的防伪cookie __RequestVerificationToken"不存在.
但它正在发送由elmah在XML日志中显示的令牌的形式
<form>
<item name="__RequestVerificationToken">
<value string="DNbDMrzHmy37GPS6IFH-EmcIh4fJ2laezIrIEev5f4vOhsY9T7SkH9-1b7GPjm92CTFtb4dGqSe2SSYrlWSNEQG1MUlNyiLP1wtYli8bIh41"/>
</item>
<item name="toPhone">
<value string="XXXXXX"/>
</item>
<item name="smsMessage">
<value string="xxxxxxxx"/>
</item>
</form>
Run Code Online (Sandbox Code Playgroud)
这是我在控制器上的方法,它使用数据属性来检查令牌是否有效
[HttpPost]
[ValidateAntiForgeryToken]
public async Task<JsonResult> Send(SMSModel model)
{
// my code goes here
}
Run Code Online (Sandbox Code Playgroud)
这是我在视图上的表单
@using (Html.BeginForm("Send", "SMS", FormMethod.Post, new { @class = "form-sms", autocomplete = "off" }))
{
@Html.AntiForgeryToken()
<div class="row">
<div class="col-md-12">
<div class="form-group">
<div class="input-group">
<div class="input-group-addon">+53</div>
@Html.TextBoxFor(m => m.toPhone, new { @class = "form-control", placeholder = "teléfono", required = "required", type = …Run Code Online (Sandbox Code Playgroud) 我正在为我的项目使用Identity Server3,我目前有一个网站和api受Id服务器保护,这工作正常但是因为我将用户存储在Id Server数据库中我无法真正更改任何用户的数据从网站上更改个人资料图片或任何索赔值.
为了解决这个问题,我正在考虑在IdServer之上创建API,这个API将管理用户,更改密码,检索用户或更改与用户相关的任何内容,我想在示例项目上创建此API我有我的IdServer使用Owin映射.
现在,我在/身份路线中的idServer就像这样
public class Startup
{
public void Configuration(IAppBuilder app)
{
Log.Logger = new LoggerConfiguration().MinimumLevel.Debug().WriteTo.Trace().CreateLogger();
app.Map("/identity", idserverApp =>
{
var efConfig = new EntityFrameworkServiceOptions
{
ConnectionString = "IdSvr3Config"
};
var options = new IdentityServerOptions
{
SiteName = "Identity server",
IssuerUri = ConfigurationManager.AppSettings["idserver:stsIssuerUri"],
PublicOrigin = ConfigurationManager.AppSettings["idserver:stsOrigen"],
SigningCertificate = Certificate.Get(),
Factory = Factory.Configure(efConfig),
AuthenticationOptions = AuthOptions.Configure(app),
CspOptions = new CspOptions { Enabled = false },
EnableWelcomePage=false
};
new TokenCleanup(efConfig, 3600 * 6).Start();
idserverApp.UseIdentityServer(options);
});
app.UseIdServerApi();
}
}
Run Code Online (Sandbox Code Playgroud)
我的api"中间件"就是这样
**public …Run Code Online (Sandbox Code Playgroud) 我正在尝试为它创建一个API和一个网站客户端.最近我一直在阅读很多关于OAuth2作为安全机制的公司以及提供身份验证作为服务的公司,例如auth0.com甚至Azure活动目录,我可以看到使用它们的优势
因为我以前总是让用户在同一个数据库和表中,以一对多的形式与Users表有关系,如下所示
public class User
{
public string subjectId { get; set; }
public virtual List<Invoice> Invoices { get; set; }
/*
More properties in here
*/
}
public class Invoice
{
public int InvoiceId { get; set; }
public string PaymentNumber { get; set; }
public DateTime Date { get; set; }
public double Amount { get; set; }
public string Description { get; set; }
public virtual User User { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
我的问题是.
如果用户存储在Auth0.com等外部认证服务中, …
我想知道如何自动更改我的应用程序的连接字符串,所以当我在我的电脑上处理它时,它使用我的本地 SQL Server,一旦我发布它,然后使用我在 azure 上托管的 SQL Server。
现在我只是根据我想要的内容注释掉连接字符串,我看到 Web.Config 文件有 2 个依赖项,Web.Debug.config 和 Web.Release.config,我想我必须做些什么但我不知道是什么。
到目前为止,这是我的 web.config 文件
<connectionStrings>
<add name="MyApp" connectionString="Data Source=mydb.database.windows.net;Initial Catalog=MyDb;User ID=MyUser@mydb.database.windows.net;Password=MyPwd;Encrypt=true;Trusted_Connection=false;" providerName="System.Data.SqlClient" />
<!--<add name="MyApp" providerName="System.Data.SqlClient" connectionString="Server=.\SQLEXPRESS;Database=MyDb;Integrated Security=True;" />-->
</connectionStrings
Run Code Online (Sandbox Code Playgroud)
如您所见,我已注释掉了 2 个连接字符串,但这样做真的很烦人。
我在 Azure 中有一个网站,该网站通过 Cloudflare 路由以获得额外保护。
Cloudflare 添加了一个标头CF-Connecting-IP,该标头应该是客户端的 IP 地址,但有时这会提供真实的 IP 地址,但大多数时候我会获得保留的 IP 地址而不是客户端的 IP。
我测试了它通过我的办公室互联网访问该网站,cloudflare 返回一个保留的 IP 地址,但是当我访问 Whatsmyip.org 时,我得到了我真实的办公室 IP 地址。
我怎样才能确保始终获得客户端的 IP 地址,除非它们位于代理或 VPN 之后。
我一直试图从过去两个小时的查询中得到结果,在我的模型中我有这个
public function getQuotes()
{
$data = Yii::app()->db->createCommand('Select fromm from city_fare_final');
$data->queryRow();
return $data ;
}
Run Code Online (Sandbox Code Playgroud)
在控制器中
public function actionIndex()
{
// renders the view file 'protected/views/site/index.php'
// using the default layout 'protected/views/layouts/main.php'
$model=new QuoteForm();
if(isset($_POST['QuoteForm']))
{
$model->attributes=$_POST['QuoteForm'];
if ($model->validate())
{
$priceTable=new CityFareFinal;
$priceTable->fromm=$model->pickupL;
$priceTable->too=$model->dropoffL;
$priceTable->type_of_car=$model->type;
this->render('result',array('model'=>$priceTable))
}
}
else
{
$this->render('index',array('model'=>$model));
}
}
Run Code Online (Sandbox Code Playgroud)
并在视图中
<div id="moduleResult">
<span><?php echo $model->getQuotes() ;?><------ Here</span>
</div>
Run Code Online (Sandbox Code Playgroud)
但它总是给我一个错误说"类CDbCommand的对象无法转换为字符串",我该怎么做才能得到我的查询结果在模型中???
关心加布里埃尔
我已经为我正在开发的 API 编写了很多集成测试。
如果我在本地运行集成测试,我想自行托管 API 并针对它运行集成测试。
但是,我在 VS Team 服务上有一个构建定义,该定义在部署 API 后运行集成测试,我想针对已部署的 API 运行测试,但要做到这一点,我必须更改我的代码,使其不再自行托管它,并且而是针对已部署的 API 进行测试。
有没有办法在运行时检测我的测试正在运行的位置?
谢谢
c# continuous-integration integration-testing asp.net-web-api2 azure-devops
我一直在使用datatable jquery(http://datatables.net/)插件.
一切都运行正常,但现在我希望能够选择多于每页记录的默认选项,默认情况下我可以选择10,25,50,100.我想在此列表中添加15和30.
我怎么能这样做,我在网上搜索但找不到任何答案.
谢谢
我需要在 el-select 组件中自定义选定的值,到目前为止,我只找到了有关自定义选项项的文档和示例,但没有找到选定后的值。这可能吗element-plus?如果是这样,请添加一个示例或为我指出正确的方向。
这些是使用槽通过自定义 HTML 自定义的选项
这是选择后的样子,我需要使用自定义 html 按选项显示
c# ×5
azure ×3
oauth-2.0 ×2
asp.net ×1
asp.net-core ×1
asp.net-mvc ×1
azure-devops ×1
cloudflare ×1
cookies ×1
datatables ×1
element-plus ×1
element-ui ×1
ip-address ×1
jquery ×1
oauth ×1
owin ×1
php ×1
vue.js ×1
vuejs3 ×1
yii ×1