MVC程序在本地没有问题,但是部署到服务器后老是跳转到Login.aspx页面,但是我的MVC程序中根本没有Login页面,看了一下链接是这样的 htttp://localhost:26290/login.aspx?ReturnUrl=%2f 查看了一下日志,出现了这样的错误

[OS:Windows 7][Browser:Mozilla][User:hwang43]System.Web.HttpException (0x80004005): 未找到路径“/login.aspx”的控制器或该控制器未实现 IController。
   在 System.Web.Mvc.DefaultControllerFactory.GetControllerInstance(RequestContext requestContext, Type controllerType)
   在 System.Web.Mvc.DefaultControllerFactory.CreateController(RequestContext requestContext, String controllerName)
   在 System.Web.Mvc.MvcHandler.ProcessRequestInit(HttpContextBase httpContext, IController& controller, IControllerFactory& factory)
   在 System.Web.Mvc.MvcHandler.BeginProcessRequest(HttpContextBase httpContext, AsyncCallback callback, Object state)
   在 System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
   在 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

原来他把Login.aspx当作了一个控制器来查找了,但是程序中又没有Login控制器,并且我在程序的Global.asax文件中也已经定义了默认页面的,

public static void RegisterRoutes(RouteCollection routes)

{

     routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

routes.MapRoute(

          name: "Default",

                    url: "{controller}/{action}/{id}",

                 defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }

);

   }

为什么没有到指定的页面呢,查找了很久,最终找到了一个解决方案,当然方法肯定不止一个,有时问题相似,但不一定就能解决,网上有一个写的也挺好,

比如这个:http://www.cnblogs.com/dudu/archive/2011/10/10/FormsAuthentication_ReturnUrl_AbsoluteUri.html

我的解决方法

第一步:在web.config文件中添加如下代码:

     <add key="autoFormsAuthentication" value="false" />

    <add key="enableSimpleMembership" value="false"/>

第二步:

在Global.asax文件中添加如下代码:

        protected void Application_PostAuthenticateRequest(object sender, EventArgs e)
{ if (!UrlAuthorizationModule.CheckUrlAccessForPrincipal(Request.AppRelativeCurrentExecutionFilePath, Context.User, Request.RequestType))
{
Response.Redirect(String.Format("{0}?ReturnUrl={1}", FormsAuthentication.LoginUrl, Request.Url.AbsoluteUri));
}
}

如果你的问题解决了,我很高兴!

如果你的问题依然没有解决,请不要骂我!

MVC程序部署后页面指向login.aspx的更多相关文章

  1. IIS安装与MVC程序部署

    最近在做访客系统,虽然说不是什么多大的项目,但麻雀虽小五脏俱全,使用EF Code First+Mysql+Frozenui响应式布局,感觉通过这个项目学到好多东西,Mysql的使用.EF映射Mysq ...

  2. spring mvc 跳转后页面cs样式表丢失

    原因:../不能正确返回 解决办法:jsp文件加<% String path = request.getContextPath(); String basePath = request.getS ...

  3. [翻译][MVC 5 + EF 6] 5:Code First数据库迁移与程序部署

    原文:Code First Migrations and Deployment with the Entity Framework in an ASP.NET MVC Application 1.启用 ...

  4. ASP.Net网站程序在编译发布部署后的后期修改

    ASP.Net网站程序在发布部署后的后期修改 作者:东篱南山 这里说的后期修改是指网站编译发布并部署好之后,对程序进行的修改,即在不能更改现有代码的情况下,更改页面的显示或是更改业务逻辑.一般是在程序 ...

  5. 用 MVC 5 的 EF6 Code First 入门 系列:MVC程序中实体框架的Code First迁移和部署

    用 MVC 5 的 EF6 Code First 入门 系列:MVC程序中实体框架的Code First迁移和部署 这是微软官方SignalR 2.0教程Getting Started with En ...

  6. 部署ASP.net MVC程序到IIS

    转:http://www.cnblogs.com/piyeyong/archive/2012/08/15/2640004.html 在网上找到一个table,列举了不同的操作系统对应的IIS版本以及配 ...

  7. IIS8发布Asp.net MVC程序后出现404错误,处理程序staticFile

    新部署的虚拟机,运行Asp.net MVC程序,出现如下图错误: 解决方法: 添加功能和角色->添加角色->Web服务器IIS->应用程序开发->Asp.net3.5 /Asp ...

  8. 编写简单的spring mvc程序,在tomcat上部署

    编写简单的spring mvc程序,在tomcat上部署 1 用java 配置spring mvc ,可以省去web.xmlpackage hello;import org.springframewo ...

  9. Centos7安装.Net Core 2.2环境以及部署.Net Core MVC程序(Apache+Jexus环境)

    原文:Centos7安装.Net Core 2.2环境以及部署.Net Core MVC程序(Apache+Jexus环境) 1.双11抢购***VPS.配置如下: CPU:2 核 内存:2048 M ...

随机推荐

  1. “玲珑杯”ACM比赛 Round #19

    A -- A simple math problem Time Limit:2s Memory Limit:128MByte Submissions:1599Solved:270 DESCRIPTIO ...

  2. struts2知识系统整理

    1.MVC 和 JSP Model 2 **   a.:M-Model 模型 包含两部分:业务数据和业务处理逻辑  b.V-View 视图:视图(View)的职责是负责显示界面和用户交互(收集用户信息 ...

  3. hdu 1848 sg——dfs&&打表双实现

    Fibonacci again and again Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Jav ...

  4. 如何解决maven archetype加载太慢的方法

    有时候在构建maven项目时,archetype加载不出来,一直在Retrieving archetype...,现象如下: 有两种解决方法: ①点击链接下载:http://files.cnblogs ...

  5. net3:Calendar控件的使用

    原文发布时间为:2008-07-29 -- 来源于本人的百度文章 [由搬家工具导入] using System;using System.Data;using System.Configuration ...

  6. 531. Lonely Pixel I

    Given a picture consisting of black and white pixels, find the number of black lonely pixels. The pi ...

  7. SPOJ MIXTURES 区间dp

    Harry Potter has n mixtures in front of him, arranged in a row. Each mixture has one of 100 differen ...

  8. linux crontab 定时器

    crontab -e 编辑定时器 crontab -l 显示当前定时器 crontab -r 删除当前定时器 格式 * * * * * command 第一列表示分钟1-59 第二列表示小时1-23 ...

  9. Ubuntu 16.04安装Mac OS 12虚拟机资源(没成功,但资源还是可以用)

    整理的Mac OS 12虚拟机资源.装虚拟机基本是按这样的套路: 1.先装VM 2.破解VM使其支持Mac OS 12,这个脚本基本是全平台支持,可以看里面的教程文档. 3.用镜像安装系统. 资源: ...

  10. [WASM] Set up wasm-bindgen for easy Rust/JavaScript Interoperability

    Interoperability between JavaScript and Rust is limited to numerics and accessing memory directly. S ...