Dev Team Assemble

Evil beware!
Add to Technorati Favorites

Archive

Tag: IIS

I started getting this error recently on my development box after I started using WSP Builder.  I really like this program but I was a little put off by this error.  Obvisouly it is recycling  the worker process or something along those lines (too lazy to look it up).  I am fine with it when it comes back online after a few seconds but I was having instances where it was hanging there...stuck in 503 limbo. 

Turns out the problem is the application pool is stuck in a stopped state and the fix is simply enough to restart it.

Technorati Tags: , , ,

Its seems that SharePoint has a knack for surprising me with seriously strange errors sometimes. Usually at the core of the error there is a sound explanation as to why this is happening but nonetheless I am not pleased with the obscurity of them sometimes. Case in point, while working on a Console application that would load FBA (Forms Based Authentication) users into a sharepoint sie collection and then create a site for each one (granting permissions and so on) I came across a very strange error - SPException: SharePoint cannot find the user.

This kind of surprised me at first and I was wondering if somehow my CustomMembershipProvider setup stopped working on my portal site, but that was fine. So after hammering away at it for a while I came across a great article written by Waldek Mastykarz on this exact problem.  After reading through his investigation it makes sense why it doesn't work in a console application but it works under the context of a SharePoint website. Essentially the web application has access to a context object and this has access to the providers node in your web.config file,  BUT the console application does not have this information available.  So when the SharePoint assemblies attempt to access this information they cannot because it does not exist.

The way around this is to create an HttpContext in your application before attempting to run SPWeb.EnsureUser("blah") like so:

if (HttpContext.Current == null) { HttpRequest request = new HttpRequest("", web.Url, ""); HttpContext.Current = new HttpContext(request, new HttpResponse(new StringWriter())); HttpContext.Current.Items["HttpHandlerSPWeb"] = web; }

Then add the system.web/membership/providers node to your app.config file (which you may have to create in the project)..  Mine looks like so:

<system.web> <membership> <providers> <add name="CustomSqlProvider" applicationName="/Portal" connectionStringName="sqlData" type="CustomProviders.CustomSqlMembershipProvider, CustomProviders, Version=1.0.0.0, Culture=neutral, PublicKeyToken=91a4fcd60b73a0e8" /> </providers> </membership> </system.web> <connectionStrings> <add name="sqlData" connectionString="Data Source=sqlpd; Initial Catalog=PUsers; Integrated Security=True; MultipleActiveResultSets=True " providerName="System.Data.SqlClient" /> </connectionStrings>

After adding this information and running a few tests it started to work. In fact it worked really well on my dev box...the only problem was it was a little intermittent on my production machine. Which is funny because the provider on the site itself works just fine all the time but in order to get my console application working (the EnsureUser() portion) the site would require an IIS reset. This is the one MAJOR stumbling block that I have yet to overcome...the only saving grace I have is that I can import the users manually into the system first using the UI and then run my console application that will load the sites and grant permissions to sites based on an external configuration file.

Many thanks to Waldek Mastykarz for all his help on this one so far...I know I will be coming back to this one in the near future but my head hurts a little and I need a beer.

Canadian SharePint event anyone?

Technorati Tags: , , , ,

I came across this neat tool (well a colleague of mine did and told me about it) from Helicon called URL Rewriter. Basically it allows you to use an ISAPI filter to rewrite the url that the server uses to work with in IIS and is essentially a copy of the mod_rewrite utility available in Apache.

It uses Regular expressions...so if you are not an expert in those (as I am clearly not) then this little tidbit of code may help. It allows you to rewrite the url that comes in as subdomain.domain.com as domain.com/subdomain. The top portion is the header and sets up logging and such...the real meat is the last two lines.

Here it is

# Helicon ISAPI_Rewrite configuration file
# Version 3.1.0.48
RewriteEngine On
RewriteCompatibility2 On
RepeatLimit 200
RewriteBase
ReWriteLog C:\rewrite.log
RewriteLogLevel 9

RewriteCond %{HTTP_HOST} ^(?!www)(\w+).christiedigital\.com
RewriteRule (.*) /%1/$1 [L]

Hope this helps

Technorati Tags: , , , ,

Inline code is disabled in sharepoint 2007 (not sure about SPS 2003) with the exception of files in the _layouts directory and will throw an error.  I was researching this a while back and thought I would throw it up here so I don't forget...maybe you can get some use out this article:

http://msdn.microsoft.com/en-us/library/bb862025.aspx

Essentially you need to add a PageParserPath entry to the web.config file for the web application

Technorati Tags: , ,

This is kind of of a weird error and it didn't make sense to me at first (still doesn't really). The best workaround I could find on the net was to temporarily change the application to run in the application pool of the central admin site.

Steps:

  1. Change the AppPool for the app to be the same as the Central Admin site (Home Directory tab in IIS website properties).
  2. Reset IIS or at the very least do an %systemroot%\system32\iisapp.vbs /a "apppoolname" /r (not sure if the iisapp.vbs method will work but cant see why not).
  3. Activate the publishing infrastructure.
  4. Set the app pool back to normal.
  5. repeat step 2.

Enjoy!

Technorati Tags: , , ,