小编gs1*_*111的帖子

在asp.net mvc中形成超时问题

如何在asp.net mvc中关闭表单身份验证。我具有旨在进入Web应用程序的注册,登录和忘记密码页面。最初我

我目前将asp.net mvc Web应用程序托管为单个代码库和多个数据库格式。我遇到表单在一段时间内过期的情况,而logon.aspx页面出现在主页的中间。我发现这是因为以下代码:

webconfig:
<authentication mode="Forms"><forms timeout="180000" slidingExpiration="false"/></authentication>

logon.cshtml:
  FormsAuthentication.SetAuthCookie(user.UserName, false);
 return RedirectToAction("Index", "Home");
Run Code Online (Sandbox Code Playgroud)

我不希望我的用户会话或表单在他们注销之前过期。如何删除身份验证模式或如何解决此超时问题?请帮忙。

这是我完整的webconfig代码:

<system.web>
    <customErrors mode="Off" />
    <globalization uiCulture="en-AU" culture="en-AU" />
    <!--<sessionState mode="InProc" />-->
    <sessionState timeout="1500"></sessionState>
    <httpRuntime encoderType="AntiXssEncoder, OnlineAB" />
    <compilation debug="true" targetFramework="4.0">
      <assemblies>
        <add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
      </assemblies>
    </compilation>
    <authentication mode="Forms">
      <forms timeout="180000" slidingExpiration="false"/>

    </authentication>
    <membership>
      <!--<providers>
        <clear />
        <add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="ApplicationServices" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" applicationName="/" />
      </providers>-->
    </membership>
    <profile>
      <!--<providers>
        <clear />
        <add name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider" …
Run Code Online (Sandbox Code Playgroud)

c# asp.net-mvc timeout forms-authentication

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

c#中的日期格式转换

如何转换04/09/2013 8:09:10 PM to 09/04/2013(MM-dd-yyyy).我试图转换,但它将09作为日期,04作为月.

请帮忙

[HttpPost]
public string getdailynote(DateTime selectedDate)
//selectedDate gets date as 04/09/2013 8:09:10 PM
{
    string x = selectedDate.ToString("MM-dd-yyy", CultureInfo.InvariantCulture);
    string daily;
    DateTime dt = Convert.ToDateTime(x);
    //dt gets value as {09/04/2013 12:00:00 AM} but 09 as date and 04 as month
    Dnote.RealDate =dt;
    daily = _scheduler.GetDailyNote(Dnote);
    return daily;
}
Run Code Online (Sandbox Code Playgroud)

c# asp.net datetime

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

mvc3 razor代码中的分析器错误

我在此代码附近的cshtml文件中收到此错误

@{      
    var options = new OpenIdSelector();
    options.TextBox.LogOnText = "Log On";
}
Run Code Online (Sandbox Code Playgroud)

分析器错误

说明:解析为此请求提供服务所需的资源时发生错误.请查看以下特定的解析错误详细信息并相应地修改源文件.

分析器错误消息:"@"字符后面出现意外的"{".一旦进入代码块的主体(@if {},@ {}等),您就不需要使用"@ {"来切换到代码.


@using DotNetOpenAuth.Mvc
@using DotNetOpenAuth.OpenId.RelyingParty
@{ 
 ViewBag.Title = "Log On"; 
}
<div id="login-oauth">
        <h3>via 3rd Party (recommended)</h3>

        @{ Html.RenderPartial("LogOnContent");}


    </div>
    <div id="or">OR</div>
    <div id="login-account">
        <h3>using a account</h3>
         </div>
    @using (Html.BeginForm())
    {
        <div>
            <p>
                <label for="username">Username:</label>
                @(Html.TextBox("username"))
                @(Html.ValidationMessage("username", "*"))
            </p>
            <p>
                <label for="password">Password:</label>
                @(Html.Password("password"))
                @(Html.ValidationMessage("password", "*"))
            </p>
            <p>
                @(Html.CheckBox("rememberMe")) <label class="inline" for="rememberMe">Remember me?</label>
            </p>
            <p>
                <input class="classiclogon" type="submit" value="Log On" />
            </p>
            <p>
                Please …
Run Code Online (Sandbox Code Playgroud)

asp.net-mvc nerddinner razor asp.net-mvc-3

0
推荐指数
1
解决办法
3245
查看次数