小编Mar*_*usz的帖子

带域域的CORS cookie仅在使用jQuery AJAX的Firefox中设置

domain使用跨站点请求添加提交时,我无法设置cookie .我试图通过jquery ajax调用请求来实现这一点.

是否有可能让它在除Firefox之外的其他浏览器中工作?

一些请求标题:

Accept:application/json, text/javascript, */*; q=0.01
Content-Length:55
Content-Type:application/x-www-form-urlencoded; charset=UTF-8
Host:localhost:53862
Origin:http://localhost:54265
Referer:http://localhost:54265/
Run Code Online (Sandbox Code Playgroud)

响应标题:

Access-Control-Allow-Credentials:true
Access-Control-Allow-Headers:x-requested-with, origin, content-type, accept, Proxy-Connection
Access-Control-Allow-Methods:GET,POST,PUT,OPTIONS, DELETE
Access-Control-Allow-Origin:http://localhost:54265
Set-Cookie:Auth=l_hash=123456&user=xyzl&remember_me=false; expires=Fri, 18 Jan 2013 13:42:10 GMT; domain=localhost; path=/
Run Code Online (Sandbox Code Playgroud)

码:

$.ajax({
    type: "PUT",
    url: apiHost + "api/account/login/",
    data: $("#loginBarForm").serialize(),
    dataType: "json",
    contentType: "application/x-www-form-urlencoded; charset=UTF-8",
    crossDomain: true,

    xhrFields: {
        withCredentials: true
    },
});
Run Code Online (Sandbox Code Playgroud)

在Firefox中一切都很好.Chrome未设置Cookie.仅当域字段被删除时,所有浏览器都在运行.我可以看到在下一个请求中(在设置cookie之后)cookie出现在标题中.响应设置cookie后的firefox请求示例(当响应有域字段时):

Cookie: Auth=l_hash=123456&user=xyz&remember_me=false
Run Code Online (Sandbox Code Playgroud)

cookies ajax jquery cors

9
推荐指数
2
解决办法
5993
查看次数

进程无法访问该文件,因为它正被另一个进程使用?

public ActionResult _Upload(HttpPostedFileBase file, GaleriesViewModel galeriesViewModel)
{
    Images image = new Images();

    if (file.ContentLength > 0)
    {
        try
        {
            var fileName = Path.GetFileName(file.FileName);
            var path = Path.Combine(Server.MapPath("~/Images/Galeries/Galery_" + galeriesViewModel.sno), fileName);
            var smallImagePath = Path.Combine(Server.MapPath("~/Images/Galeries/Small/Galery_" + galeriesViewModel.sno), fileName);
            var db_file_url = "Images/Galeries/Galery_" + galeriesViewModel.sno + "/" + fileName;
            var db_small_image_url = "Images/Galeries/Small/Galery_" + galeriesViewModel.sno + "/" + fileName;

            //exception thrown in this line
            file.SaveAs(path);
            Image smallImage = Image.FromFile(path);
            Size size = new Size();
            size.Height = 128;
            size.Width = 128;
            smallImage = …
Run Code Online (Sandbox Code Playgroud)

asp.net-mvc dispose file-upload image process

2
推荐指数
1
解决办法
2431
查看次数

标签 统计

ajax ×1

asp.net-mvc ×1

cookies ×1

cors ×1

dispose ×1

file-upload ×1

image ×1

jquery ×1

process ×1