Web Deploy: (401) Unauthorized

If you are getting the 401 Unauthorized error from Visual Studio when trying to use Web Deploy, then (because of a Bug in Web Deploy (also version 2)) add this to your regedit:

at HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System

add DWORD: LocalAccountTokenFilterPolicy with value: 1.

Now you can use a windows user that is a member of your admin group (not the native admin) to deploy your content!

6 comments

IIS6: The service did not respond to the start or control request in a timely fashion

After a Windows Update on our Win2003 server, we suddently received this message when trying to stop or start an app pool or website.

For our particular situation I found the answer on JessWatts.com:

"It is possible that a shared dll that IIS 6 relies on has become unregistered.
Try running the following command: regsvr32 qmgr.dll
Then reboot the server and start the failed websites.
"

Thanks Jess!

No comments, yet!

Solr delete/clear index

To delete/clear the solr index.

Simply run both of these in the browser (change the "solr" name and port to your specific solr instance name if the default wasn't used):

1. http://localhost:8080/solr/update?stream.body=%3Cdelete%3E%3Cquery%3E*:*%3C/query%3E%3C/delete%3E
2. http://localhost:8080/solr/update?stream.body=%3Ccommit/%3E

Performance with Entity Framework

 Here are some links to great resources if you are looking to build high-performance enterprise website solutions:

Microsoft is moving fast these days. The entity framework is getting more functionality and structure as it progresses. It seems to be implementing several best practice patterns such as repository and unit of work patterns among others.

Sql Profiler - Analyzing number of database calls

Is your pageload taking more than 0.2 seconds! its time to investigate how many database roundtrips your webapplication is making. If you haven't got Sql Profiler (with MS Sql Server) go download AnjLab Sql Profiler its free.

To identify database roundtrips from an application, Setup the following events:

RPC:Completed SQL:BatchCompleted

And this filter: TextData Not Like exec sp_reset_connection%

Source: Jeremy Jameson - http://blogs.msdn.com/b/jjameson/archive/2010/09/03/analyzing-database-roundtrips-with-sql-server-profiler.aspx

IIS Application Pool Queue Length Settings

This is hard to find information:

The default limit for an application pool is 4000 requests. On a moderately sized server with a few application pools configured, this might be a good value. However, on a server with multiple CPUs and lots of RAM, this value might be too low. On a server with limited resources or many application pools configured, this value might be too high. Here you might want to use a formula of Memory Size in Megabytes x Number of CPUs x 10 divided by Number of Configured Application Pools to determine what the size of the average request queue should be. This is meant to be a guideline to give you a starting point for consideration and not an absolute rule. For example, on a server with two CPUs, 1024 MB of RAM, and twenty configured application pools, the size of the average request queue limit would be around 1,000 requests. You might have some application pools configured with request queue limits of 750 and others with request queue limits of 1,250. However, if the same server had only one configured application pool, you probably wouldn’t configure a request queue limit of 10,000.

Source: http://forums.asp.net/p/623323/623323.aspx (Matthew, Microsoft).

Dealing with TC/CS DateFormats

Defining a specific date format in TC (and CS (Community Server)) can be tricky. An example could be: "30 september, 2003" or "01-01-2010".

First you need to know that all the users you may have registered in your database will not be affected by changes made to the default date format defined in the controlpanel. They each need to select a new date format in their profile settings to get a new date format.

Working with a new TC website you should define the preferred date format before any users are registered:

  1. Search for "Utility_DateFormatDropDownList_F1" in your language files located in the "languages" folder.
  2. Edit one or more of the defined date formats if your preferred format is not already defined. Reset the application pool (iisreset).
  3. Goto yourwebsite.com/controlpanel/Settings/Setup.aspx and select the preferred date format. Press "Save".

From this time forward new users will be preselected to use the date format selected. They can still at any time goto their profile settings to select a different format from the dropdown list unless you simply remove this from the template :).

The defaultDate defined in the web.config file can be disregarded.

Scandinavian letters (ÆØÅ) in javascript formatting!

For future reference I am writing this post: ÆØÅ in JavaScript - simply save .js file as UTF-8 formatting! On how to save in UTF-8 encoding in Visual Studio 2010 see this answer: UTF-8 Encoding at Stackoverflow.

TC 5.5 Localization

Everything in Telligent Community is becoming increasingly complex. A simple feature as localization has once again been filtered into the database. Its important to know if you are translating TC into a none-english language that profile field names and profile widget headlines are located in controlpanel (Membership) and not in the language files where they belong!

UPDATE: The widget headlines can be defined in codebehind and thus reference the language files. The profile fields can also reference the language file if defined in the theme.config file! Adding them adhoc is still an issue.

CSControl:Pager Template Styling

Styling the pager control in Community Server always escapes me so here is an example:

<CSControl:Pager id="pager" runat="Server" Tag="div" style='text-align: center;'>
<FirstLinkTemplate>
  <CSControl:CSLinkData LinkTo="Link" LinkCssClass="TextButton" runat="server"><ContentTemplate><span><span>Newest</span></span></ContentTemplate></CSControl:CSLinkData>
</FirstLinkTemplate>
<PreviousLinkTemplate>
  <CSControl:CSLinkData LinkTo="Link" LinkCssClass="TextButton" runat="server"><ContentTemplate><span><span>Newer</span></span></ContentTemplate></CSControl:CSLinkData>
</PreviousLinkTemplate>
<PageLinkTemplate>
  <CSControl:CSLinkData LinkTo="Link" Property="Text" Text="<span><span>{0}</span></span>" LinkCssClass="TextButton" runat="server" />
</PageLinkTemplate>
<CurrentPageLinkTemplate>
  <CSControl:CSLinkData Tag="Span" CssClass="TextButtonDisabled" Property="Text" Text="<span><span>{0}</span></span>" runat="server" />
</CurrentPageLinkTemplate>
<SeparatorTemplate></SeparatorTemplate>
<NextLinkTemplate>
  <CSControl:CSLinkData LinkTo="Link" LinkCssClass="TextButton" runat="server"><ContentTemplate><span><span>Older</span></span></ContentTemplate></CSControl:CSLinkData>
</NextLinkTemplate>
<LastLinkTemplate>
  <CSControl:CSLinkData LinkTo="Link" LinkCssClass="TextButton" runat="server"><ContentTemplate><span><span>Oldest</span></span></ContentTemplate></CSControl:CSLinkData>
</LastLinkTemplate>
</CSControl:Pager>

Source: http://getben.com/archive/2007/01/30/introduction-to-chameleon-questions-and-answers.aspx

Visual Studio (VS) 2010 Build Configuration dropdown

If you happen to be missing the Build configuration dropdown menu from your toolbar in Visual Studio 2010 and can't find it in the Build toolbar here is how you add it back in:

Tools -> Customize -> Commands (tab). Select "Toolbar:" and then select "Build" from the dropdown.

Click on "Add Command", select "Build" in Categories and find "Solution Configurations" (at the bottom). Click "Ok" and it is back in the "Build" toolbar!

No comments, yet!

Entity Framework 4.0 RC: Cannot insert the value NULL into column '*_Id', table 'Paragraphs'; column does not allow nulls. INSERT fails. The statement has been terminated.

Entity Framework 4.0 RC bug. Usually after an "update model from database" I encounter this error message: Cannot insert the value NULL into column '*_Id', table 'column does not allow nulls. INSERT fails. The statement has been terminated.

To fix the association between the many-to-one relationship (in my case Paragraphs to Translation), you need to edit the .edmx model file and remove StoreGeneratedPattern="Identity" from the Paragraphs node.

See more here: http://stackoverflow.com/questions/2243618/how-do-you-insert-or-update-many-to-many-tables-in-net-entity-framework/2339834#2339834

No comments, yet!

LINQ to Entities - Common queries (.Net 4.0)

T-Sql "WHERE IN":

Sql:

SELECT * FROM People
WHERE Firstname IN ('Peter', 'Steve', 'John', 'Bruno')


LINQ:

var names = new string[] { "Peter", "Steve", "John", "Bruno" };

var matches = from person in people
        where names.Contains(person.Firstname)
        select person;

No comments, yet!

Encrypting connectionstrings.config in IIS 6.0

Simply call these two commands in cmd prompt:

  1. C:\WINDOWS\microsoft.net\Framework64\v2.0.50727\aspnet_regiis.exe -pef "connectionStrings" C:\MyWebsiteFolder
  2. C:\WINDOWS\microsoft.net\Framework64\v2.0.50727\aspnet_regiis -pa "NetFrameworkConfigurationKey" "Network Service"

If you still get a: "Failed to decrypt using provider 'RsaProtectedConfigurationProvider'. Error message from the provider: The RSA key container could not be opened." Then call the second command again but replace "Network Service" with "ASPNET".

Source: MS Patterns & Practices: http://msdn.microsoft.com/en-us/library/ms998283.aspx

T-SQL Dynamic Sorting and Order By

Using the CASE expression its possible to do efficient sorting and ordering by different parameters in one query. Here is an example from Greg Beech's Tech Blog which also includes paging:

 

DECLARE @SortType TINYINT, @SortAscending BIT, @FirstRow INT, @MaxRows INT;
SELECT @SortType = 2, @SortAscending = 0, @FirstRow = 10, @MaxRows = 10;

WITH FoundCustomers AS
(
    SELECT
        ROW_NUMBER() OVER
        (
            ORDER BY
                CASE WHEN @SortType = 0 AND @SortAscending = 1 THEN c.ContactName END ASC
                ,CASE WHEN @SortType = 0 AND @SortAscending = 0 THEN c.ContactName END DESC
                ,CASE WHEN @SortType = 1 AND @SortAscending = 1 THEN c.CompanyName END ASC
                ,CASE WHEN @SortType = 1 AND @SortAscending = 0 THEN c.CompanyName END DESC
                ,CASE WHEN @SortType = 2 AND @SortAscending = 1 THEN c.Country END ASC
                ,CASE WHEN @SortType = 2 AND @SortAscending = 0 THEN c.Country END DESC
        ) AS RowNumber
        ,c.*
    FROM
        dbo.Customers c
)
SELECT
    fc.*
FROM
    FoundCustomers fc
WHERE
    fc.RowNumber BETWEEN @FirstRow AND @FirstRow + @MaxRows - 1
ORDER BY
    fc.RowNumber;
More Posts Next page »

What is weblogs?

Lunarmedia weblogs is a combination of blog posts submitted by Lunarmedia and an aggregate mirrored list from Lunarmedia websites.

Most discussed