微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

NGINX Ajax主体后面的Razor Pages已删除

如何解决NGINX Ajax主体后面的Razor Pages已删除

我的Razor页面PathBase = sbm。

当我尝试在cshtml页面中进行Ajax调用时,@Url.Page("/Index","Login")将转换为/sbm?handler=Login

大部分时间都在工作,直到我将其放到Nginx后面。以下Ajax调用删除主体。

$.ajax({
    url: "/sbm?handler=Login",// auto generated from @Url.Page("/Index","Login")
    type: "POST",data: { id: 'test' },// **This is missing from my request body**
    headers: { "RequestVerificationToken": $('input[name="__RequestVerificationToken"]').val() }
})

如果我对"/sbm/Index?handler=Login"进行硬编码而不是使用@Url.Page("Index","Login"),那么一切都会起作用

我真的不知道Nginx为什么会剥离尸体。以下是我的Nginx配置

#user  nobody;
worker_processes  1;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/Nginx.pid;


events {
    worker_connections  1024;
}


http {
include       mime.types;
#types {
#   text/html  aspx;
#}
default_type  application/octet-stream;

#log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
#                  '$status $body_bytes_sent "$http_referer" '
#                  '"$http_user_agent" "$http_x_forwarded_for"';

#access_log  logs/access.log  main;

sendfile        on;
#tcp_nopush     on;

#keepalive_timeout  0;
keepalive_timeout  65;

#gzip  on;

server {
    listen                    *:443 ssl;
server_name               example.com;
    ssl_certificate           /Shared/SSL/mybundle.crt;
    ssl_certificate_key       /Shared/SSL/private.key;
    ssl_protocols             TLSv1.1 TLSv1.2;
    ssl_prefer_server_ciphers on;
    ssl_ciphers               "EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH";
    ssl_ecdh_curve            secp384r1;
    ssl_session_cache         shared:SSL:10m;
    ssl_session_tickets       off;
    ssl_stapling              on; #ensure your cert is capable
    ssl_stapling_verify       on; #ensure your cert is capable

    add_header Strict-Transport-Security "max-age=63072000; includeSubdomains; preload";
    add_header x-frame-options DENY;
    add_header X-Content-Type-Options nosniff;

    proxy_set_header Host $http_host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;

    location /sbm/ {
        proxy_pass  http://127.0.0.1:5012/sbm/;

    #proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;
    #proxy_set_header   X-Forwarded-Proto $scheme;
        expires -1;
    }

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。