表单身份验证重定向问题 [英] Forms authentication redirect issue

查看:85
本文介绍了表单身份验证重定向问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用不同的角色superadmin,hr assistant等重定向到分别在文件夹中的aspx页面。但是在服务器中它让我重定向为zainasoft / Account / Login.aspx?ReturnUrl =%2fzainasoft%2fHRManager%2fDashboard.aspx。 ...



我实际上是重定向到HRManager / Dashboard.aspx ......

我的web.config如下:

I am redirecting using different roles superadmin,hr assistant etc to aspx pages with in folders respectively..But in server it keeps me redirecting as zainasoft/Account/Login.aspx?ReturnUrl=%2fzainasoft%2fHRManager%2fDashboard.aspx ....

I am actualy redirecting to HRManager/Dashboard.aspx......
My web.config as follows:

<!--
  For more information on how to configure your ASP.NET application, please visit
  http://go.microsoft.com/fwlink/?LinkId=169433
  -->
<configuration>
	<configsections>
		<sectiongroup name="devExpress">
			<section name="settings" type="DevExpress.Web.ASPxClasses.SettingsConfigurationSection, DevExpress.Web.v12.1, Version=12.1.6.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" requirepermission="false" />
			<section name="compression" type="DevExpress.Web.ASPxClasses.CompressionConfigurationSection, DevExpress.Web.v12.1, Version=12.1.6.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" requirepermission="false" />
			<section name="themes" type="DevExpress.Web.ASPxClasses.ThemesConfigurationSection, DevExpress.Web.v12.1, Version=12.1.6.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" requirepermission="false" />
			<section name="errors" type="DevExpress.Web.ASPxClasses.ErrorsConfigurationSection, DevExpress.Web.v12.1, Version=12.1.6.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" requirepermission="false" />
		</sectiongroup>
		<sectiongroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
			<section name="ResumeManager.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirepermission="false" />
		</sectiongroup>
	</configsections>
	<appsettings>
		&lt;!--<add key="connect" value="server=ZS-SERVER;Initial Catalog=ResumeNakilat;User ID=sa;Password=star@123;Connect Timeout=200; pooling='true';Max Pool Size=200" />--&gt;
		&lt;!--<add key="connect" value="server=ZS-SERVER;Initial Catalog=resumedbzaina;User ID=sa;Password=star@123;Connect Timeout=200; pooling='true';Max Pool Size=200" />--&gt;
		<add key="connect" value="server=SOUTHERN-PC;Initial Catalog=resumedbzaina;User ID=sa;Password=sa;Connect Timeout=200; pooling='true';Max Pool Size=200" />
		&lt;!--<add key="connects" value="server=ZS-SERVER;Initial Catalog=resumedbzaina;User ID=sa;Password=star@123" />--&gt;
    <add key="connects" value="server=SOUTHERN-PC;Initial Catalog=resumedbzaina;User ID=sa;Password=sa" />
		<add key="SMTPServer" value="mail.zainasoft.com" />
		<add key="FromAddressInfo" value="careers@zainasoft.com" />
		<add key="SMTPCredentialUser" value="careers@zainasoft.com" />
		<add key="SMTPCredentialPass" value="password" />
    <add key="autoFormsAuthentication" value="false" />
    <add key="enableSimpleMembership" value="false" />
		<add key="MailBee.Global.LicenseKey" value="MN700-0123456789ABCDEF-0123" />
		<add key="ChartImageHandler" value="storage=file;timeout=20;" />
		<add key="FolderPath" value="RecruiterCandidatedocs" />
	</appsettings>
	<connectionstrings>
  <add name="ConnectionString" connectionstring="Data Source=SOUTHERN-PC;Initial Catalog=resumedbzaina;User ID=sa;Password=sa;Connect Timeout=200; pooling='true'; Max Pool Size=200">
   providerName="System.Data.SqlClient" /&gt;
  <add name="ApplicationServices" connectionstring="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnetdb.mdf;User Instance=true">
   providerName="System.Data.SqlClient" /&gt;
  <add name="resumedbzainaConnectionString" connectionstring="Data Source=ZS-SERVER;Initial Catalog=resumedbzaina;User ID=sa">
   providerName="System.Data.SqlClient" /&gt;
  <add name="resumedbzainaConnectionString1" connectionstring="Data Source=ZS-SERVER;Initial Catalog=resumedbzaina;Persist Security Info=True;User ID=sa;Password=star@123">
   providerName="System.Data.SqlClient" /&gt;
  <add name="ConnectionString2" connectionstring="Expression: XtraCarsConnectionString">
   providerName="System.Data.SqlClient" /&gt;
  <add name="resumedbzainaConnectionString2" connectionstring="Data Source=ZS-SERVER;Initial Catalog=resumedbzaina;User ID=sa;Password=star@123">
   providerName="System.Data.SqlClient" /&gt;
  <add name="resumedbzainaConnectionString3" connectionstring="Data Source=FAIZREHAN-PC\SQLEXPRESS;Initial Catalog=resumedbzaina;Persist Security Info=True;User ID=sa">
   providerName="System.Data.SqlClient" /&gt;
  <add name="resumedbzainaConnectionString4" connectionstring="Data Source=SOUTHERN-PC;Initial Catalog=resumedbzaina;User ID=sa;Password=sa">
   providerName="System.Data.SqlClient" /&gt;
 </add></add></add></add></add></add></add></add></connectionstrings>
	<system.web>
    <identity impersonate="true" />
		<pages controlrenderingcompatibilityversion="3.5" validaterequest="false" clientidmode="AutoID">
			<controls>
				<add tagprefix="asp" namespace="System.Web.UI.DataVisualization.Charting" assembly="System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
			</controls>
		</pages>
		<sessionstate mode="InProc" timeout="525600"></sessionstate>
		<customerrors mode="Off" />
		<compilation debug="true" targetframework="4.0">
			<assemblies>
				<add assembly="DevExpress.Web.ASPxEditors.v12.1, Version=12.1.6.0, Culture=neutral, PublicKeyToken=B88D1754D700E49A" />
				<add assembly="DevExpress.Web.ASPxThemes.v12.1, Version=12.1.6.0, Culture=neutral, PublicKeyToken=B88D1754D700E49A" />
				<add assembly="DevExpress.Web.v12.1, Version=12.1.6.0, Culture=neutral, PublicKeyToken=B88D1754D700E49A" />
				<add assembly="DevExpress.Data.v12.1, Version=12.1.6.0, Culture=neutral, PublicKeyToken=B88D1754D700E49A" />
				<add assembly="DevExpress.XtraReports.v12.1.Web, Version=12.1.6.0, Culture=neutral, PublicKeyToken=B88D1754D700E49A" />
				<add assembly="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
				<add assembly="System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
				<add assembly="DevExpress.Printing.v12.1.Core, Version=12.1.6.0, Culture=neutral, PublicKeyToken=B88D1754D700E49A" />
				<add assembly="DevExpress.XtraReports.v12.1, Version=12.1.6.0, Culture=neutral, PublicKeyToken=B88D1754D700E49A" />
				<add assembly="DevExpress.Utils.v12.1, Version=12.1.6.0, Culture=neutral, PublicKeyToken=B88D1754D700E49A" />
				<add assembly="DevExpress.XtraCharts.v12.1.Web, Version=12.1.6.0, Culture=neutral, PublicKeyToken=B88D1754D700E49A" />
				<add assembly="DevExpress.Web.ASPxEditors.v12.1, Version=12.1.6.0, Culture=neutral, PublicKeyToken=B88D1754D700E49A" />
				<add assembly="DevExpress.Web.v12.1, Version=12.1.6.0, Culture=neutral, PublicKeyToken=B88D1754D700E49A" />
				<add assembly="DevExpress.Data.v12.1, Version=12.1.6.0, Culture=neutral, PublicKeyToken=B88D1754D700E49A" />
				<add assembly="DevExpress.Web.ASPxGridView.v12.1.Export, Version=12.1.6.0, Culture=neutral, PublicKeyToken=B88D1754D700E49A" />
				<add assembly="DevExpress.XtraPrinting.v12.1, Version=12.1.6.0, Culture=neutral, PublicKeyToken=B88D1754D700E49A" />
				<add assembly="System.Web.Extensions.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
				<add assembly="DevExpress.Web.ASPxScheduler.v12.1, Version=12.1.6.0, Culture=neutral, PublicKeyToken=B88D1754D700E49A" />
				<add assembly="DevExpress.XtraScheduler.v12.1.Core, Version=12.1.6.0, Culture=neutral, PublicKeyToken=B88D1754D700E49A" /></assemblies>
		</compilation>
		<authentication mode="Forms">
			&lt;forms loginUrl="~/Account/Login.aspx" timeout="2880"/&gt;
		</authentication>
		<membership defaultprovider="AspNetSqlMembershipProviderRelaxed">
			<providers>
				<clear />
				<add connectionstringname="ConnectionString" applicationname="/" maxinvalidpasswordattempts="10" enablepasswordretrieval="false" enablepasswordreset="true" requiresquestionandanswer="false" passwordstrengthregularexpression="" minrequiredpasswordlength="1" minrequirednonalphanumericcharacters="0" name="AspNetSqlMembershipProviderRelaxed" type="System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
			</providers>
		</membership>
		<rolemanager enabled="true">
			<providers>
				<clear />
				<remove name="AspNetSqlRoleProvider" />
				<add name="AspNetSqlRoleProvider" connectionstringname="ConnectionString" applicationname="/" type="System.Web.Security.SqlRoleProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
			</providers>
		</rolemanager>
		<httpruntime requestvalidationmode="2.0" maxrequestlength="102400" executiontimeout="3600" />
		<httpmodules>
			<add type="DevExpress.Web.ASPxClasses.ASPxHttpHandlerModule, DevExpress.Web.v12.1, Version=12.1.6.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" name="ASPxHttpHandlerModule" />
		</httpmodules>
		<httphandlers>
			<add path="ChartImg.axd" verb="GET,HEAD,POST" type="System.Web.UI.DataVisualization.Charting.ChartHttpHandler, System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" validate="false" />
			<add path="ASPxUploadProgressHandlerPage.ashx" verb="GET,POST" type="DevExpress.Web.ASPxUploadControl.ASPxUploadProgressHttpHandler, DevExpress.Web.v12.1, Version=12.1.6.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" validate="false" />
			<add path="DX.ashx" verb="GET,POST" type="DevExpress.Web.ASPxClasses.ASPxHttpHandlerModule, DevExpress.Web.v12.1, Version=12.1.6.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" validate="false" />
		</httphandlers>
	</system.web>
	<system.webserver>
		<defaultdocument enabled="true">
			<files>
				<clear />
				<add value="Login.aspx" />
			</files>
		</defaultdocument>
		<modules runallmanagedmodulesforallrequests="true">
			<add type="DevExpress.Web.ASPxClasses.ASPxHttpHandlerModule, DevExpress.Web.v12.1, Version=12.1.6.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" name="ASPxHttpHandlerModule" />
		</modules>
		<validation validateintegratedmodeconfiguration="false" />
		<handlers>
			<remove name="ChartImageHandler" />
			<add type="DevExpress.Web.ASPxUploadControl.ASPxUploadProgressHttpHandler, DevExpress.Web.v12.1, Version=12.1.6.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" verb="GET,POST" path="ASPxUploadProgressHandlerPage.ashx" name="ASPxUploadProgressHandler" precondition="integratedMode" />
			<add type="DevExpress.Web.ASPxClasses.ASPxHttpHandlerModule, DevExpress.Web.v12.1, Version=12.1.6.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" verb="GET,POST" path="DX.ashx" name="ASPxHttpHandlerModule" precondition="integratedMode" />
			<add name="ChartImageHandler" precondition="integratedMode" verb="GET,HEAD,POST" path="ChartImg.axd" type="System.Web.UI.DataVisualization.Charting.ChartHttpHandler, System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
		</handlers>
		<httpprotocol>
			<customheaders>
				<clear />
				<add name="X-UA-Compatible" value="IE=9" />
			</customheaders>
		</httpprotocol>
	</system.webserver>
	<devexpress>
		<settings righttoleft="false" />
		<compression enablehtmlcompression="false" enablecallbackcompression="true" enableresourcecompression="true" enableresourcemerging="false" />
		<themes enablethemesassembly="true" stylesheettheme="" theme="" />
		<errors callbackerrorredirecturl="" />
	</devexpress>
	<applicationsettings>
		<resumemanager.properties.settings>
			<setting name="ResumeManager_localhost_WebService1" serializeas="String">
				<value>http://localhost:51919/WebService1.asmx</value>
			</setting>
		</resumemanager.properties.settings>
	</applicationsettings>
</configuration>

推荐答案

1st of All I’’d like to suggest you not to provide the whole original config file in forums.

Also for better understanding of your question we just need the FormsAuthentication code lines, not anything else.



Anyway what I’’m getting from your problem, you want to redirect to different pages according to different Roles.

SO if I’’m right I think the following code block can help you.



1st of All I''d like to suggest you not to provide the whole original config file in forums.
Also for better understanding of your question we just need the FormsAuthentication code lines, not anything else.

Anyway what I''m getting from your problem, you want to redirect to different pages according to different Roles.
SO if I''m right I think the following code block can help you.

protected void Button1_Click(object sender, EventArgs e)
    {
        //You can Implement Logic to check which User/Role is Logging In as well
        if (Request.Params["ReturnUrl"] != null)
        {
            FormsAuthentication.RedirectFromLoginPage(txtUserName.Text, false);
        }
        else
        {
            FormsAuthentication.SetAuthCookie(txtUserName.Text, false);
            Response.Redirect("HRManager/Dashboard.aspx");
        }
    }





Still you didn’’t get anything Feel Free to ask.



Regards



Still you didn''t get anything Feel Free to ask.

Regards


这篇关于表单身份验证重定向问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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