我为我的网站使用了两个项目.一个用于Mvc项目和Api项目.我在web.config文件中添加了以下代码,该文件位于Api项目中,
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: GET, POST, PUT, DELETE
Access-Control-Allow-Headers: Authorization
Run Code Online (Sandbox Code Playgroud)
Api项目中的动作方法如下,
[HttpPost]
[Route("api/ajaxapi/caselistmethod")]
public List<CaseValues> AjaxCaseListMethod()
{
List<CaseValues> caseList = new List<CaseValues>();
return caseList;
}
Run Code Online (Sandbox Code Playgroud)
和ajax调用如下,这是在Mvc项目中,
$.ajax({
type: "POST",
url: "http://localhost:55016/api/ajaxapi/caselistmethod",
beforeSend: function (request) {
request.setRequestHeader("Authorization", getCookie("Token"));
},
success: function (response) {
}
});
Run Code Online (Sandbox Code Playgroud)
但是显示如下错误,
选项http:// localhost:55016/api/ajaxapi/caselistmethod 405(方法不允许)XMLHttpRequest无法加载http:// localhost:55016/api/ajaxapi/caselistmethod.预检的响应具有无效的HTTP状态代码405
但没有Header工作正常.我也需要传递标题.所以请提出任何建议.
谢谢...
我已经在这个窗口中创建了主窗口,创建了停靠面板,用于在主窗口中绑定用户控件值,如下所示,
<Window x:Class="WpfApplication2.DMMainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
ResizeMode="NoResize"
WindowState="Maximized"
WindowStyle="None"
WindowStartupLocation="CenterScreen"
Height="{Binding SystemParameters.PrimaryScreenHeight}"
Width="{Binding SystemParameters.PrimaryScreenWidth}">
<DockPanel Width="1254" Height="1200" HorizontalAlignment="Left" Margin="0,0,0,0" x:Name="mainPanel" VerticalAlignment="Top" />
</Window>
Run Code Online (Sandbox Code Playgroud)
在此代码中,您可以看到停靠面板的给定宽度和高度。我需要这个高度和宽度需要绑定为与窗口宽度相同。我使用了实际的宽度和高度以及大小到内容,但没有发生预期的情况。请提出您的建议。