WebPartエラーの解決方法


Introduction
ASP.NET 2.0 provides a Web Parts framework, allowing programmers to easily integrate drag ’n drop menus etc. in their web portals. This framework is easy to use and all client based design settings are stored by ASP.NET data providers in an easy way. The developer has nothing to do with the save or load process of Web Parts design based settings. This article will not cover how we can use Web Parts. It’s possible to find lots of articles around the web about Web Parts.
ASP.NET 2.0 Web Parts framework works with the Membership framework as well as the Forms or Windows authentication modes. The problem is that, if you don’t want to use any authentication mode, you can’t use Web Parts. The client user, who will able to change the web site's design with Web Parts, should be authenticated. If not authenticated, the ASP.NET Web Parts framework can’t save users' design settings with data providers and for that reason can’t allow even to switch design modes.
The Idea
First, we will set up our web site for Forms Authentication. You just need to modify your Web.Config file as below:
        <!--
            The <authentication> section enables configuration 
            of the security authentication mode used by 
            ASP.NET to identify an incoming user. 
        -->
        <authentication mode="Forms" />
second,we can coding same code on Page_Load event
 FormsAuthenticationTicket t = new FormsAuthenticationTicket(      
 1, "WebPart", DateTime.Now, DateTime.Now.AddHours(100), false,
 "WebPart", FormsAuthentication.FormsCookiePath);    
Response.Cookies.Add(new HttpCookie(FormsAuthentication.FormsCookieName,FormsAuthentication.Encrypt(t)));