申请AccountController.LogOn失败时在MVC preVIEW 2 [英] fails in MVC Preview 2 when applying to AccountController.LogOn

查看:215
本文介绍了申请AccountController.LogOn失败时在MVC preVIEW 2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当试图在ASP.NET MVC 2 preVIEW应用[RequireHttps]到AccountController.Logon 2我收到以下错误:

When trying to apply [RequireHttps] to AccountController.Logon in ASP.NET MVC 2 Preview 2 I get the following error :

ASP.NET检测无效字符在URL中。

ASP.NET detected invalid characters in the URL.

这是因为ASP.NET改写从

This is because ASP.NET has rewritten my request from

http://example.com/admin

https://example.com/account/logon%3FReturnUrl=/admin

这是ASP.NET本身已添加 RETURNURL (不ASP.NET MVC),但它是 RequireHttps 属性被重定向和搞乱了网址。

It is ASP.NET itself that has added ReturnURL (not ASP.NET MVC), but it is the RequireHttps attribute that is redirecting and messing up the URL.

%3F 而不是更是打破了网页。

The %3F instead of ? is breaking the page.

我认为它在技术上在ASP.NET中的错误。有没有解决办法?
我想,也许一种方式在Global.asax中处理未验证事件 - 或者可能刚刚杀青的RequireHttpsAttribute源

I think its technically a bug in ASP.NET. Is there a workaround? I'm thinking maybe a way to handle the 'unauthenticated' event in global.asax - or possibly just fixing the source for RequireHttpsAttribute.

    [RequireHttps]
    public ActionResult LogOn()
    {
        return View(DefaultModel);
    }

    <authentication mode="Forms">
       <forms loginUrl="~/account/logon"/>
    </authentication>

下面是一个<一个href=\"http://stackoverflow.com/questions/1645999/requirehttps-fails-on-redirects-with-parameters\">similar,但不同的问题

编辑:我只是想在 http://example.com/accout/login?cat=dog 手动输入,它仍然重定向为无效的网址:帐户/登录%3Fcat =狗。我本来以为这是关系到成员资格提供程序之间的冲突和 [RequireHttps] 但它看起来像只是一个基本的错误,所以我想我得刚修好源我自己。

I just tried manually entering in http://example.com/accout/login?cat=dog and it still redirected to an invalid URL : account/logon%3Fcat=dog. I originally thought it was related to a conflict between the membership provider and [RequireHttps] but it looks like just a basic bug so I think I'll have to just fix the source myself.

推荐答案

这似乎定格在ASP.NET MVC2 RC。

This appears fixed in ASP.NET MVC2 RC.

 /admin

现在被改写为正确的网址:

now gets rewritten to the correct URL:

 /account/logon?ReturnUrl=/admin

这篇关于申请AccountController.LogOn失败时在MVC preVIEW 2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆