Welcome

Sharepoint lead is a place where you can read about interesting topics related to sharepoint, and you can also post comments and suggessions.
Showing posts with label SharePoint 2013. Show all posts
Showing posts with label SharePoint 2013. Show all posts

Wednesday, April 23, 2014

ascx.g.cs Empty

Bug:
In Visual Studio 2012, when you are working with a visual web part, your user control's ascx.g.cs file becomes empty. So you get an error "The name ‘InitializeControl’ does not exist in the current context".

Root cause:
This is reported as a bug in visual studio 2012 and it generally happens when your server side mark up is having issues. This ONLY happens when you are editing your ascx file.

Suggested Solution:
You can try following:
Short way:

  • try to undo some of the last changes in ascx file.
  • Create copy of ascx file and revert it from source control. Rename g.cs to g.txt and switch to ascx and hit save. That will generate another g.cs with correct content

Long way:

  • Please check the @Register declarations against the TagPrefix and TagName that you are using.
  •  Try to comment out all controls in ascx and save it. That will generate ascx.g.cs along with content again. Now start un-commenting the controls one by one.
  • In worst cases, after trying lots of things people also switch to new web part and migrate useful code from the problematic web part step by step to resolve the error. 

Sunday, January 6, 2013

System.ArgumentException: Exception of type 'System.ArgumentException' was thrown. Parameter name: encodedValue

I was configuring one of our clients farm which required FBA on different web applications (around 5) and he wanted each web application should have separate user store. That was too tricky since you just need to set up Application property of the membership provider and you are done.
After completion of these settings, all of my applications were having a common exception either in log out or login to the web application. Here was the exception.
System.ArgumentException: Exception of type 'System.ArgumentException' was thrown.  Parameter name: encodedValue    at Microsoft.SharePoint.Administration.Claims.SPClaimEncodingManager.DecodeClaimFromFormsSuffix(String encodedValue)     at Microsoft.SharePoint.Administration.Claims.SPClaimProviderManager.GetProviderUserKey(IClaimsIdentity claimsIdentity, String encodedIdentityClaimSuffix)     at Microsoft.SharePoint.Administration.Claims.SPClaimProviderManager.GetProviderUserKey(String encodedIdentityClaimSuffix)     at Microsoft.SharePoint.Utilities.SPUtility.GetFullUserKeyFromLoginName(String loginName)     at Microsoft.SharePoint.ApplicationRuntime.SPHeaderManager.AddIsapiHeaders(HttpContext context, String encodedUrl, NameValueCollection headers)     at Microsoft.SharePoint.ApplicationRuntime.SPRequestModule.PreRequestExecuteAppHandler(Object oSender, EventArgs ea)     at System.Web.HttpApplication.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()     at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
After checking all my steps right through starting. After getting all the other exeptions cleared the above exception was the only exception that I was getting. That was resolved using "Exception of type 'System.ArgumentException' was thrown" got error when i have signout from webapplication in sharepoint 2010?.
I hope this will help to you if you are getting same error due to a silly custom property of a custom web part for registration!

Update - 5/19/2014

There are several solutions that I tried:
The same error also encountered again reported by client when he tries to enable intranet through internet explorer settings. Disabling detection of intranet from internet options solves that issue but you are forced to enter username password every first visit of the site even in intranet as well!

Update - 5/25/2014

This is a SharePoint bug also found some discussion here: https://sharepoint2013fba.codeplex.com/workitem/9 

Hope this helps

Friday, December 28, 2012

SharePoint 2013 FBA Pack

I tried to install SharePoint 2010 FBA Pack in SharePoint 2013 and it was working almost OK. I started facing some minor issues and I fixed them one by one.

Entire solution with my fixes is available as a BitBucket repository here

Following are list of issues and how I fixed them.

  1. When you go to add new user from user manager, and click on cancel, it was showing error
    Solution:
    Replaced code
    string url = "FBA/Management/UsersDisp.aspx";
                SPUtility.DetermineRedirectUrl(url,SPRedirectFlags.RelativeToLayoutsPage, this.Context,null, out url);
    with
    string url = "/_layouts/FBA/Management/UsersDisp.aspx";
                //SPUtility.DetermineRedirectUrl(url,SPRedirectFlags.RelativeToLayoutsPage, this.Context,null, out url);
    So, in nutshell, when you are using the previous code, it redirects to /_layouts/15/FBA/UserDisp.aspx and our actual path is in 14 folder.
  2. Similar redirection problems where there when you click edit user and click on cancel, click on reset password and click on cancel etc. I fixed them all by replacing SPUtility.Redirect to Response.Redirect
  3. Use of upgraded user controls.
    When you go to any page, for example UserNew.aspx, you will notice that there are controls used in the page that are registered from "_controltemplates/xxxx.ascx", I upgraded them to use "_controltemplates/15/xxxx.ascx.
    You must be wondering how did I come to know about this? I looked at the page in 15 hive's admin folder and some random aspx page over there, I noticed the new path.
  4. Last one was, Due to SharePoint 2013 titles, breadcrumbs where causing long scroll. I updated resource file to update titles. I just updated titles and used "Manage Users", "Add Users" in place of using all long titles that are used out of the box.
  5. When I tried to package the solution after changes are done, It was giving me too long path error, so I renamed project name and package name to FBA. You will still able to install/upgrade it using stsadmin command.
This are really simple and small fixes, and only contains minor changes that make you able to work. If you have any other bugs, just post it to the public BitBucket repository that I have created and I will try to help you.

In next couple of posts we will discuss about adding customer properties through profile provider. If you have any other sugessions or feedback, I will be more than happy to hear back.