مرجع تخصصی برنامه نویسان

انجمن تخصصی برنامه نویسان فارسی زبان

کاربر سایت

negarin

عضویت از 1396/01/05

rturnurl تو صفحه لاگین من کار نمیکند

  • شنبه 25 شهریور 1396
  • 16:40
تشکر میکنم

ببخشید، من یک پورتال دارم که بعد تایم خاصی خود به خود logout میشود اما بعد از لاگین مجدد من وارد صفحه دیفالت میرود و کل دیتا های ورودی ام میپرد و با توجه به سرچ هایی که کردم از returnUrl استفاده کردم اما اصلا کار نمیکند کدم را به پیوست ارسال مینمایم

پاسخ های این پرسش

تعداد پاسخ ها : 14 پاسخ
کاربر سایت

سهیل علیزاده

عضویت از 1396/04/09

  • شنبه 25 شهریور 1396
  • 16:43

متن سوال خود را اصلاح و واضح تر توضیح بدید.

کاربر سایت

ایمان مدائنی

عضویت از 1392/01/20

  • شنبه 25 شهریور 1396
  • 17:15

چگونه صفحه جاری را پیدا میکنید تا بعد از لاگین هدایت کنید ؟

کد را از طریق ادیتور قرار دهید

کاربر سایت

negarin

عضویت از 1396/01/05

  • یکشنبه 26 شهریور 1396
  • 08:23
System.Web.HttpContext.Current.Request.UrlReferrer;
اما مشکلش اینه که تو هر صفحه ای باشم آدرس روت پیج میده 
مثلا تو هرصفحه ای http://localhost:15940/ نشان میده از هر صفحه ای بیاد همه راه حل های اینترنتم رفتم
کاربر سایت

mvc_esmaeili

عضویت از 1395/08/22

  • یکشنبه 26 شهریور 1396
  • 09:10
تنظیمات global.asax یا webconfig قسمت appstart شاید اونجا پیش فرض تعریف شده که مسیر شما را قبول نمیکند
کاربر سایت

negarin

عضویت از 1396/01/05

  • یکشنبه 26 شهریور 1396
  • 09:14

صلا appstart ندارم توی سولوشن

        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            routes.MapRoute(
                name: "Default",
                url: "{controller}/{action}/{id}",
                defaults: new { controller = "Account", action = "Login", id = UrlParameter.Optional }
            );
        }

این منظورتون؟

کاربر سایت

ایمان مدائنی

عضویت از 1392/01/20

  • یکشنبه 26 شهریور 1396
  • 09:24

کد لاگین و تنیمات وب کانفیگ را قرار دهید

کاربر سایت

negarin

عضویت از 1396/01/05

  • یکشنبه 26 شهریور 1396
  • 09:28

using System;
using System.Globalization;
using System.Linq;
using System.Security.Claims;
using System.Threading.Tasks;
using System.Web;
using System.Web.Mvc;
using Microsoft.AspNet.Identity;
using Microsoft.AspNet.Identity.Owin;
using Microsoft.Owin.Security;
using FACPSP.Models;

namespace FACPSP.Controllers
{
    //[Authorize]
    public class AccountController : Controller
    {
        private FACPSPEntities db = new FACPSPEntities();
        public AccountController()
        {
        }

        public AccountController(ApplicationUserManager userManager, ApplicationSignInManager signInManager )
        {

        }

        [AllowAnonymous]
        public ActionResult Login(string returnUrl)
        {
            if (Request.IsAuthenticated)
            {
                return RedirectToAction("Cartable", "Action");
            }
            else
            {
               ViewBag.ReturnUrl = returnUrl;
            return View(); 
            }
            
        }

        //
        // POST: /Account/Login
        [HttpPost]
        [AllowAnonymous]
        [ValidateAntiForgeryToken]
        public ActionResult Login(LoginViewModel model, string returnUrl)
        {
            if (!ModelState.IsValid)
            {
                return View(model);
            }
            var currentUser =
                db.Personnels.FirstOrDefault(p => !p.isDeleted && p.UserName == model.UserName && p.Password == model.Password);
            if (currentUser == null)
            {
                ModelState.AddModelError("", "نام کاربری یا کلمه عبور اشتباه است.");
                return View(model);
            }
            UserInformation userinfo = new UserInformation
            {
                UserName = currentUser.UserName,
                AgentId = currentUser.Agent_Id,
                UserId = currentUser.Id
            };
            if (currentUser.Person.IsRealPerson)
            {
                userinfo.Name = currentUser.Person.RealPeople.FirstName;
                userinfo.Family = currentUser.Person.RealPeople.LastName;
                userinfo.NationalCode = currentUser.Person.RealPeople.NationalCode;
            }
            else
            {
                userinfo.Name = currentUser.Person.LegalPeople.Title;
                userinfo.Family = "";
                userinfo.NationalCode = currentUser.Person.LegalPeople.NationalCode;
            }
            userinfo.CanSeeTerminalStateIds = currentUser.Role.RoleStates.Select(rs => rs.State_Id).ToList();
            userinfo.CanUpdateTerminalStateIds = currentUser.Role.RoleStates.Where(rs=>rs.CanUpdate).Select(rs => rs.State_Id).ToList();
            var x = Request.UrlReferrer.ToString();
            Session.Add("UserInformation", userinfo);
            return RedirectToAction("MyNextAction",
      new { r = Request.Url.ToString() });

        }
        public ActionResult MyNextAction()
        {
            return Redirect(Request.QueryString["r"]);
        }

        [AllowAnonymous]
        public ActionResult LogOff()
        {
            return RedirectToAction("Login", "Account");
        }
    }
}

webConfiq

<?xml version="1.0"?>
<!--
  For more information on how to configure your ASP.NET application, please visit
  http://go.microsoft.com/fwlink/?LinkId=301880
  -->
<configuration>
  <configSections>
    <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false"/>
  </configSections>
  <connectionStrings>
    <!--<add name="DefaultConnection" connectionString="Data Source=(LocalDb)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\aspnet-FACPSP-20160827055928.mdf;Initial Catalog=aspnet-FACPSP-20160827055928;Integrated Security=True" providerName="System.Data.SqlClient" />-->
    <!--<add name="FACPSPDB" connectionString="metadata=res://*/FACPSPDB.csdl|res://*/FACPSPDB.ssdl|res://*/FACPSPDB.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=DAIS3D-LAPTOP\MSSQL14;initial catalog=FACPSP;user id=sa;password=Password;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" />-->
    <!--<add name="FACPSPDB" connectionString="metadata=res://*/FACPSPDB.csdl|res://*/FACPSPDB.ssdl|res://*/FACPSPDB.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=.;initial catalog=FACPSP;user id=sa;password=3860350293;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" />
    <add name="FACPSPEntities" connectionString="metadata=res://*/FACPSPDB.csdl|res://*/FACPSPDB.ssdl|res://*/FACPSPDB.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=.;initial catalog=FACPSP;user id=sa;password=3860350293;multipleactiveresultsets=True;application name=EntityFramework&quot;" providerName="System.Data.EntityClient" />-->
    <!--<add name="FACPSPDB" connectionString="metadata=res://*/FACPSPDB.csdl|res://*/FACPSPDB.ssdl|res://*/FACPSPDB.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=.;initial catalog=FACPSP;user id=shahsavand;password=Loyalty1396;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" />
    <add name="FACPSPEntities" connectionString="metadata=res://*/FACPSPDB.csdl|res://*/FACPSPDB.ssdl|res://*/FACPSPDB.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=.;initial catalog=FACPSP;user id=shahsavand;password=Loyalty1396;multipleactiveresultsets=True;application name=EntityFramework&quot;" providerName="System.Data.EntityClient" />-->
    <add name="FACPSPEntities" connectionString="metadata=res://*/FACPSPDB.csdl|res://*/FACPSPDB.ssdl|res://*/FACPSPDB.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=172.16.20.5;initial catalog=FACPSP-DEV;persist security info=True;user id=sa;password=bsa;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient"/>
  </connectionStrings>
  <appSettings>
    <add key="webpages:Version" value="3.0.0.0"/>
    <add key="webpages:Enabled" value="false"/>
    <add key="ClientValidationEnabled" value="true"/>
    <add key="UnobtrusiveJavaScriptEnabled" value="true"/>
  </appSettings>
  <system.web>
    <authentication mode="None"/>
    <!--<compilation debug="true" targetFramework="4.6.1" />-->
    <httpRuntime targetFramework="4.6.1" maxRequestLength="32768000"/>
    <httpModules>
      <add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web"/>
    </httpModules>
    <compilation debug="true"/>
  </system.web>
  <system.webServer>
    <modules>
      <remove name="FormsAuthentication"/>
      <remove name="ApplicationInsightsWebTracking"/>
      <add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web" preCondition="managedHandler"/>
    </modules>
    <validation validateIntegratedModeConfiguration="false"/>
  </system.webServer>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.Owin.Security" publicKeyToken="31bf3856ad364e35"/>
        <bindingRedirect oldVersion="0.0.0.0-3.0.1.0" newVersion="3.0.1.0"/>
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.Owin.Security.OAuth" publicKeyToken="31bf3856ad364e35"/>
        <bindingRedirect oldVersion="0.0.0.0-3.0.1.0" newVersion="3.0.1.0"/>
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.Owin.Security.Cookies" publicKeyToken="31bf3856ad364e35"/>
        <bindingRedirect oldVersion="0.0.0.0-3.0.1.0" newVersion="3.0.1.0"/>
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.Owin" publicKeyToken="31bf3856ad364e35"/>
        <bindingRedirect oldVersion="0.0.0.0-3.0.1.0" newVersion="3.0.1.0"/>
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Newtonsoft.Json" culture="neutral" publicKeyToken="30ad4fe6b2a6aeed"/>
        <bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0"/>
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Optimization" publicKeyToken="31bf3856ad364e35"/>
        <bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="1.1.0.0"/>
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35"/>
        <bindingRedirect oldVersion="0.0.0.0-1.5.2.14234" newVersion="1.5.2.14234"/>
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35"/>
        <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0"/>
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35"/>
        <bindingRedirect oldVersion="1.0.0.0-5.2.3.0" newVersion="5.2.3.0"/>
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35"/>
        <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0"/>
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
  <entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
      <parameters>
        <parameter value="mssqllocaldb"/>
      </parameters>
    </defaultConnectionFactory>
    <providers>
      <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer"/>
    </providers>
  </entityFramework>
  <system.codedom>
    <compilers>
      <compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:6 /nowarn:1659;1699;1701"/>
      <compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:14 /nowarn:41008 /define:_MYTYPE=\&quot;Web\&quot; /optionInfer+"/>
    </compilers>
  </system.codedom>
</configuration>

کاربر سایت

negarin

عضویت از 1396/01/05

  • یکشنبه 26 شهریور 1396
  • 10:27

میشه راهنمایی کنید؟

کاربر سایت

سهیل علیزاده

عضویت از 1396/04/09

  • یکشنبه 26 شهریور 1396
  • 10:37

کدهاتون را با فرمت کد قرار بدید تا بتوانیم آن را بررسی کنیم.

کاربر سایت

negarin

عضویت از 1396/01/05

  • یکشنبه 26 شهریور 1396
  • 10:53
using System;
using System.Globalization;
using System.Linq;
using System.Security.Claims;
using System.Threading.Tasks;
using System.Web;
using System.Web.Mvc;
using System.Web.Security;
using Microsoft.AspNet.Identity;
using Microsoft.AspNet.Identity.Owin;
using Microsoft.Owin.Security;
using FACPSP.Models;

namespace FACPSP.Controllers
{
    //[Authorize]
    public class AccountController : Controller
    {
        private FACPSPEntities db = new FACPSPEntities();
        [AllowAnonymous]
        public ActionResult Login(string returnUrl)
        {
            //So that the user can be referred back to where they were when they click logon
            if (string.IsNullOrEmpty(returnUrl) && Request.UrlReferrer != null)
                returnUrl = Server.UrlEncode(Request.UrlReferrer.PathAndQuery);

            if (Url.IsLocalUrl(returnUrl) && !string.IsNullOrEmpty(returnUrl))
            {
                ViewBag.ReturnURL = returnUrl;
            }
            ViewBag.ReturnURL = returnUrl;
            return View();

        }

        //
        // POST: /Account/Login
        [HttpPost]
        [AllowAnonymous]
        [ValidateAntiForgeryToken]
        public ActionResult Login(LoginViewModel model, string returnUrl)
        {
            string decodedUrl = "";
            if (!string.IsNullOrEmpty(returnUrl))
                decodedUrl = Server.UrlDecode(returnUrl);
            if (!ModelState.IsValid)
            {
                return View(model);
            }
            var currentUser =
                db.Personnels.FirstOrDefault(p => !p.isDeleted && p.UserName == model.UserName && p.Password == model.Password);
            if (currentUser == null)
            {
                ModelState.AddModelError("", "نام کاربری یا کلمه عبور اشتباه است.");
                return View(model);
            }
            UserInformation userinfo = new UserInformation
            {
                UserName = currentUser.UserName,
                AgentId = currentUser.Agent_Id,
                UserId = currentUser.Id
            };
            if (currentUser.Person.IsRealPerson)
            {
                userinfo.Name = currentUser.Person.RealPeople.FirstName;
                userinfo.Family = currentUser.Person.RealPeople.LastName;
                userinfo.NationalCode = currentUser.Person.RealPeople.NationalCode;
            }
            else
            {
                userinfo.Name = currentUser.Person.LegalPeople.Title;
                userinfo.Family = "";
                userinfo.NationalCode = currentUser.Person.LegalPeople.NationalCode;
            }
            userinfo.CanSeeTerminalStateIds = currentUser.Role.RoleStates.Select(rs => rs.State_Id).ToList();
            userinfo.CanUpdateTerminalStateIds = currentUser.Role.RoleStates.Where(rs=>rs.CanUpdate).Select(rs => rs.State_Id).ToList();
            if (Url.IsLocalUrl(decodedUrl))
            {
                return Redirect(decodedUrl);
            }
            else
            {
                return RedirectToAction("Index", "Home");
            }

        }


        [AllowAnonymous]
        public ActionResult LogOff()
        {
            FormsAuthentication.SignOut();
            return Redirect("/");
        }
    }
}

و فایل وب کانفیگ برنامه

<?xml version="1.0"?>
<!--
  For more information on how to configure your ASP.NET application, please visit
  http://go.microsoft.com/fwlink/?LinkId=301880
  -->
<configuration>
  <configSections>
    <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false"/>
  </configSections>
  <connectionStrings>
    <!--<add name="DefaultConnection" connectionString="Data Source=(LocalDb)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\aspnet-FACPSP-20160827055928.mdf;Initial Catalog=aspnet-FACPSP-20160827055928;Integrated Security=True" providerName="System.Data.SqlClient" />-->
    <!--<add name="FACPSPDB" connectionString="metadata=res://*/FACPSPDB.csdl|res://*/FACPSPDB.ssdl|res://*/FACPSPDB.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=DAIS3D-LAPTOP\MSSQL14;initial catalog=FACPSP;user id=sa;password=Password;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" />-->
    <!--<add name="FACPSPDB" connectionString="metadata=res://*/FACPSPDB.csdl|res://*/FACPSPDB.ssdl|res://*/FACPSPDB.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=.;initial catalog=FACPSP;user id=sa;password=3860350293;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" />
    <add name="FACPSPEntities" connectionString="metadata=res://*/FACPSPDB.csdl|res://*/FACPSPDB.ssdl|res://*/FACPSPDB.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=.;initial catalog=FACPSP;user id=sa;password=3860350293;multipleactiveresultsets=True;application name=EntityFramework&quot;" providerName="System.Data.EntityClient" />-->
    <!--<add name="FACPSPDB" connectionString="metadata=res://*/FACPSPDB.csdl|res://*/FACPSPDB.ssdl|res://*/FACPSPDB.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=.;initial catalog=FACPSP;user id=shahsavand;password=Loyalty1396;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" />
    <add name="FACPSPEntities" connectionString="metadata=res://*/FACPSPDB.csdl|res://*/FACPSPDB.ssdl|res://*/FACPSPDB.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=.;initial catalog=FACPSP;user id=shahsavand;password=Loyalty1396;multipleactiveresultsets=True;application name=EntityFramework&quot;" providerName="System.Data.EntityClient" />-->
    <add name="FACPSPEntities" connectionString="metadata=res://*/FACPSPDB.csdl|res://*/FACPSPDB.ssdl|res://*/FACPSPDB.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=172.16.20.5;initial catalog=FACPSP-DEV;persist security info=True;user id=sa;password=bsa;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient"/>
  </connectionStrings>
  <appSettings>
    <add key="webpages:Version" value="3.0.0.0"/>
    <add key="webpages:Enabled" value="false"/>
    <add key="ClientValidationEnabled" value="true"/>
    <add key="UnobtrusiveJavaScriptEnabled" value="true"/>
  </appSettings>
  <system.web>
    <authentication mode="None"/>
    <sessionState mode="InProc" timeout="15" />
    <!--<compilation debug="true" targetFramework="4.6.1" />-->
    <httpRuntime targetFramework="4.6.1" maxRequestLength="32768000"/>
    <httpModules>
      <add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web"/>
    </httpModules>
    <compilation debug="true"/>
  </system.web>
  <system.webServer>
    <modules>
      <remove name="FormsAuthentication"/>
      <remove name="ApplicationInsightsWebTracking"/>
      <add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web" preCondition="managedHandler"/>
    </modules>
    <validation validateIntegratedModeConfiguration="false"/>
  </system.webServer>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.Owin.Security" publicKeyToken="31bf3856ad364e35"/>
        <bindingRedirect oldVersion="0.0.0.0-3.0.1.0" newVersion="3.0.1.0"/>
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.Owin.Security.OAuth" publicKeyToken="31bf3856ad364e35"/>
        <bindingRedirect oldVersion="0.0.0.0-3.0.1.0" newVersion="3.0.1.0"/>
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.Owin.Security.Cookies" publicKeyToken="31bf3856ad364e35"/>
        <bindingRedirect oldVersion="0.0.0.0-3.0.1.0" newVersion="3.0.1.0"/>
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.Owin" publicKeyToken="31bf3856ad364e35"/>
        <bindingRedirect oldVersion="0.0.0.0-3.0.1.0" newVersion="3.0.1.0"/>
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Newtonsoft.Json" culture="neutral" publicKeyToken="30ad4fe6b2a6aeed"/>
        <bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0"/>
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Optimization" publicKeyToken="31bf3856ad364e35"/>
        <bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="1.1.0.0"/>
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35"/>
        <bindingRedirect oldVersion="0.0.0.0-1.5.2.14234" newVersion="1.5.2.14234"/>
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35"/>
        <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0"/>
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35"/>
        <bindingRedirect oldVersion="1.0.0.0-5.2.3.0" newVersion="5.2.3.0"/>
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35"/>
        <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0"/>
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
  <entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
      <parameters>
        <parameter value="mssqllocaldb"/>
      </parameters>
    </defaultConnectionFactory>
    <providers>
      <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer"/>
    </providers>
  </entityFramework>
  <system.codedom>
    <compilers>
      <compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:6 /nowarn:1659;1699;1701"/>
      <compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:14 /nowarn:41008 /define:_MYTYPE=\&quot;Web\&quot; /optionInfer+"/>
    </compilers>
  </system.codedom>
</configuration>

کاربر سایت

سهیل علیزاده

عضویت از 1396/04/09

  • یکشنبه 26 شهریور 1396
  • 11:09

View مربوط به Login را قرار دهید.

کاربر سایت

ایمان مدائنی

عضویت از 1392/01/20

  • یکشنبه 26 شهریور 1396
  • 11:20

احراز هویت را باید روی Forms بزارید

<authentication mode="None"/>

کاربر سایت

negarin

عضویت از 1396/01/05

  • یکشنبه 26 شهریور 1396
  • 11:36
@using FACPSP.Models
@model LoginViewModel
@{
    ViewBag.Title = Fa_IR.LogIn;
    Layout = "../Shared/_LoginLayout.cshtml";
}
<div class="container">
    @using (Html.BeginForm("Login", "Account",FormMethod.Post, new { @class = "form-signin" }))
  
    {
        @Html.HiddenFor(c=>c.returnUrl)
        @Html.AntiForgeryToken()
        <h2 class="form-signin-heading">@Fa_IR.ApplicationName</h2>
        @Html.ValidationSummary(true, "", new { @class = "text-danger dirRtl" })
        <div class="login-wrap">
            @Html.ValidationMessageFor(m => m.UserName, "", new { @class = "text-danger" })
            @Html.TextBoxFor(m => m.UserName, new { @class = "form-control", @placeholder = Fa_IR.UserName, @autofocus = true })
            <br/>
            @Html.ValidationMessageFor(m => m.Password, "", new { @class = "text-danger" })
            @Html.PasswordFor(m => m.Password, new { @class = "form-control", @placeholder = Fa_IR.Password })
            <button class="btn btn-lg btn-login btn-block" type="submit">@Fa_IR.LogIn</button>
        </div>
    }
</div>



@section Scripts {
    @Scripts.Render("~/bundles/jqueryval")
}

از هر صفحه ای که بخوام لاگین کنم با هر رفرش میره صفحه لاگین از ابتدا

کاربر سایت

سهیل علیزاده

عضویت از 1396/04/09

  • یکشنبه 26 شهریور 1396
  • 11:40

شما از  ViewBag در View استفاده نکردید کد فرم را به شکل زیر تغییر دهید:

            @using (Html.BeginForm("Login", "Account", new { returnUrl = ViewBag.ReturnURL }, FormMethod.Post, new { @class = "form-signin" }))

کاربرانی که از این پست تشکر کرده اند

هیچ کاربری تا کنون از این پست تشکر نکرده است

اگر نیاز به یک مشاور در زمینه طراحی سایت ، برنامه نویسی و بازاریابی الکترونیکی دارید

با ما تماس بگیرید تا در این مسیر همراهتان باشیم :)