次の方法で共有


Unable to change the DisplayMode of a WebPartManager

I had an issue where I was changing a WebPartManger's displaymode using the following code...

WebPartManager1.DisplayMode = WebPartManager.CatalogDisplayMode
or
WebPartManager1.DisplayMode = WebPartManager.EditDisplayMode

I didn't use SQL Express for my database. Instead I was using my Web.config to configure my SQL 2000 to store Website's information as follows...

<connectionStrings>
<remove name="LocalSqlServer"/>
<add name="LocalSqlServer" connectionString="Data Source=localhost;Initial Catalog=aspnetdb;Integrated Security=True" providerName="System.Data.SqlClient"/>
</connectionStrings>

Whenever I tried to browse my page, it worked fine. But as soon as I tried to change the DisplayMode here is the error message which I got...

Server Error in '/WebPartBlogFinal' Application.


The specified display mode is currently disabled on this page. Make sure personalization is enabled for the current user.
Parameter name: value

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.ArgumentException: The specified display mode is currently disabled on this page. Make sure personalization is enabled for the current user.
Parameter name: value
Stack Trace:

[ArgumentException: The specified display mode is currently disabled on this page. Make sure personalization is enabled for the current user.
Parameter name: value]
System.Web.UI.WebControls.WebParts.WebPartManager.set_DisplayMode(WebPartDisplayMode value) +864643
ASP.default_aspx.CustomizePage(Object s, EventArgs e) in c:\inetpub\wwwroot\WebPartBlogFinal\Default.aspx:4
System.Web.UI.WebControls.LinkButton.OnClick(EventArgs e) +105
System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String eventArgument) +107
System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +174
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5102

Version Information: Microsoft .NET Framework Version:2.0.50727.42; ASP.NET Version:2.0.50727.42

To solve this error...

I had my "Enable Anonymous Access" Checked along with "Integrated Windows Authentication"
I unchecked my "Enable Anonymous Access" and ran the application again. Now, it works just fine.

In case you want to reproduce this issue, try the code from https://blogs.msdn.com/rahulso/archive/2006/03/18/554590.aspx

Create a website against your IIS and instead of SQLExpress use, SQL Server and configure it as the <connectionStrings> above.
Now, run the application with Anonymous access and it should fail. With Integrated Authentication it shouldn't.

Download the Express Edition of Microsoft SQL Server Management Studio. Management Studio Express (SSMSE) provides a graphical management tool for SQL Server 2005 Express Edition (SQL Server Express) instances. https://www.microsoft.com/downloads/details.aspx?familyid=82afbd59-57a4-455e-a2d6-1d4c98d40f6e&displaylang=en

Hope that helps.

Comments

  • Anonymous
    June 15, 2007
    Hi Rahul, the solution that u have provided is really good. It works. Tnx for it.

  • Anonymous
    March 16, 2008
    my Os is Vista so this did't work with me i disable anonymous authintication & enabled windows authintication but it didn't work it ask me for username and password can any one help me in that

  • Anonymous
    March 06, 2009
    Thanks Rahul It saved my time :) and it will save others too :)

  • Anonymous
    July 08, 2009
    Better way : http://www.codeproject.com/KB/aspnet/anonywebparts.aspx

  • Anonymous
    September 17, 2009
    I am facing issue "The specified display mode is currently disabled on this page. Make sure personalization is enabled for the current user." I have done following :

  1. In web.config <authentication mode="Windows" />
  2. I turned off anonymous domain access.
  3. I tried to browse the page and it prompts me for user name and password. I gave it properly on and on but after 3 attempts it gave me "you are not authorized..." message. Please note that we can not set <authentication mode="Forms" /> in web.config. Please let me know if you require more info. Thanks for early reply. Ashutosh