0

I've created an generic http handler (ashx) that creates sites based on a particular custom web template I have created. However I'm getting a strange error when I execute the GetWebTemplates method.

Basically it throws an formatexception with the message

"Input string was not in a correct format"

Any ideas? My code:

  using (SPSite thisSite = new SPSite(web.Site.ID))
            {
                SPWebTemplateCollection templates = thisSite.GetWebTemplates(1033);
                SPWebTemplate siteTemplate = null;

                foreach (SPWebTemplate template in templates)
                {
                    if (template.Title.Equals(title))
                    {
                        siteTemplate = template;
                        break;
                    }
                }

                return siteTemplate;           
            }
1

This indeed is strange. I have tested your code in my development environment and it runs with no errors. Could perhaps your site collection be damaged somehow? I would try creating a fresh site collection (heck, maybe even a fresh web application...) just to check. If it runs OK against the new SPSite, you'll need to figure out what's wrong with the current one.

  • 1
    So, have you figured out what the problem was? – nixx Jan 28 '14 at 9:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.