ASP.NET MVC4 发布服务器后 无法登陆

Soul2016 2018-02-07 11:24:44

我用VS2013 写的一个登陆 MVC4页面 ,提交是用AJAX。

问题:
发布到 Windows 服务器2008 ,就无法登陆。 用谷歌 显示
好像AJAX 没起作用,提示 信息“

Failed to load resource: the server responded with a status of 404 (Not Found)” ----------- Login/CheckLogin

大概是无法找到我的控制器方法 Login/CheckLogin。

-----------------------------------------------------
备注:
在VS2013 或 发布本地 进行登陆都没有问题,在上一家公司 ,发布到 Windows 服务器2008 也一样没有问题。到新公司服务器就....

网上说配置CONFIG,可以还是没作用。
<remove name="AjaxHandlerFactory"/>
<add name="AjaxHandlerFactory" verb="POST,GET" path="ajax/*." preCondition="integratedMode" type="Ajax.PageHandlerFactory, Ajax"/>

请帮忙看看,谢谢!



...全文
1129 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
Soul2016 2018-02-23
  • 打赏
  • 举报
回复
引用 8 楼 starfd 的回复:
果然是一二级目录问题,你看下F12具体地址就知道为啥了,如果是cshtml模板里面,你可以改成Url.Action来生成连接,如果是在Js里面,你可以在前面加上../,这样应该能解决路径问题
非常谢谢~ 是这样,年前忙忘记回复,祝您 越来越帅!
春天的气息 2018-02-18
  • 打赏
  • 举报
回复
和操作系统里的IIS配置有关系,程序的移植也是很重要的。
  • 打赏
  • 举报
回复
你是发布在一级目录还是二级目录?是不是路径问题
Soul2016 2018-02-08
  • 打赏
  • 举报
回复
看了 谷歌浏览器 显示 : xhr.send( options.hasContent && options.data || null ); 报错 是什么问题? (使用低版本的JQuery 也一样报类似错误 ,Post 不出去) 公司使用域名 用户,就登录而已,不存在跨域问题吧 ,帮忙看看 谢谢~
  • 打赏
  • 举报
回复
果然是一二级目录问题,你看下F12具体地址就知道为啥了,如果是cshtml模板里面,你可以改成Url.Action来生成连接,如果是在Js里面,你可以在前面加上../,这样应该能解决路径问题
Soul2016 2018-02-08
  • 打赏
  • 举报
回复
同一个程序文件 在同一服务器 同一个位置(就是同一个 程序路径) 一个发布到 默认站点下面 ,默认端口80的,可以访问,登录 不了(报这个错 xhr.send( options.hasContent && options.data || null ); ) 一个发布到 不是默认站点,命名BLM ,用IP 端口 就可以 访问和 登录,不报错。 程序在本地是电脑发布也是没问题。 求助 帮忙看看,谢谢``
Soul2016 2018-02-08
  • 打赏
  • 举报
回复
引用 5 楼 starfd 的回复:
你是发布在一级目录还是二级目录?是不是路径问题


谢谢版主~

看截图:


我程序 发布到 默认 站点下面 ---命名为 Bartender ,以http://XXX/Bartender 就可以访问(XXX:表示公司内域名地址或服务器名),但登陆有问题,报Jquery 文件。 xhr.send( options.hasContent && options.data || null ); 导致无法登陆。

如果我把程序发布 叫 BLM ,并设置IP 和端口 。类似:http:// 10.22.251.11:8081 这样就可以登录,没有问题。
Soul2016 2018-02-07
  • 打赏
  • 举报
回复
问题应该和这个 https://www.telerik.com/forums/failed-to-load-resource-the-server-responded-with-a-status-of-404-not-found 很类似。 我 .NET Frame 4.7 最新的,AJAX 和这个应该没有关系。
Soul2016 2018-02-07
  • 打赏
  • 举报
回复

            $.ajax({
                url: "/Login/CheckLogin",
                data: { username: $.trim(username), password: $.trim(password), verifycode: verifycode},
                type: "post",
                dataType: "json",
                success: function (data) {
                    if (data.type == 1)
                    {

                        window.location.href = '@Url.Action("AdminDefault", "Home")';

                    } else
                    {
                    }
                },
                error: function (data) {
                    alert(data.type);
                }
            });
直接跳到 报错 提示:返回空, alert(data.type); 代码在本地及本地IIS发布都可以登录 及 其他公司服务器发布都可以登录的。就是目前公司服务器发布登录不了。直接返回错误
秋的红果实 2018-02-07
  • 打赏
  • 举报
回复
先不要config,用默认设置,检查ajax提交代码的url地址是不是有效
An outstanding author team presents the ultimate Wrox guide to ASP.NET MVC 4 Microsoft insiders join giants of the software development community to offer this in-depth guide to ASP.NET MVC, an essential web development technology. Experienced .NET and ASP.NET developers will find all the important information they need to build dynamic, data-driven websites with ASP.NET and the newest release of Microsoft's Model-View-Controller technology. Featuring step-by-step guidance and lots of code samples, this guide gets you started and moves all the way to advanced topics, using plenty of examples. Designed to give experienced .NET and ASP.NET programmers everything needed to work with the newest version of MVC technology Expert author team includes Microsoft ASP.NET MVC insiders as well as leaders of the programming community Covers controllers, views, models, forms and HTML helpers, data annotation and validation, membership, authorization, security, and routing Includes essential topics such as Ajax and jQuery, NuGet, dependency injection, unit testing, extending MVC, and Razor Includes additional real-world coverage requested by readers of the previous edition as well as a new case study example chapter 下面是上一版书的中文介绍 《ASP.NET MVC 3 高级编程》主要内容是描述视图的概念,探讨Razor语法、NuGet、单元测试等,解释控制器在MVC框架中的作用,以及模型在绑定和数据访问策略中发挥的作用,演示如何显示和处理表单,涵盖添加到April 2011 Tools Update中的新特性,如基架和HTML5项目模板,展示在客户端和服务器端验证模型的过程给出利用成员资格、援权和安全特性的忠告,讲解将TDD应用于ASP.NET MVC的方法。

62,051

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧