SharePoint / ASP.Net Development
Experiences from the field
Navigation
   RSS 2.0
Categories
Entries by Month

# Monday, January 31, 2005

I wrote in my previous post that you should use http to access web part resources. Well guess what -- there is more to it.

If your WSS site is running with anonymous access off, then the attempt to get the resource will fail with a 401 Unauthorized error. This happens because web requests made in code will perform an anonymous GET.

In my specific case, I was attempting to read an XSLT file from the resource directory by passing the URL to the file. To solve the security issue, the Load() method on the XslTransform object needs a security resolver. The code necessary for this (which I copied from the .Net SDK):

' Build the URI to the resource
Dim resourceURI As Uri = New Uri(ClassResourcePath)
Dim xslPath As String = Path.Combine(resourceURI.ToString(), "filename.xsl")

' Create a secure resolver with default credentials.
Dim resolver as XmlUrlResolver = new XmlUrlResolver()
Dim sResolver as XmlSecureResolver = new XmlSecureResolver(resolver, xslPath)
sResolver.Credentials = CredentialCache.DefaultCredentials

' Get the xsl file
Dim trn As XslTransform = New XslTransform
trn.Load(xslPath, sResolver)

Monday, January 31, 2005 2:14:25 PM (Central Standard Time, UTC-06:00)  #    Comments [0]  | 
# Thursday, January 27, 2005

If you have a resource required by a web part, WSS has a defined way to store and access this resource. Custom web parts can be deployed to the wwwroot/bin directory or to the global assembly cache (GAC). The deployment location also affects the location of the resources directory. For GAC deployments, the directory is mapped to /_wpresources/[assembly_name]. For bin directory deployments, the directory is mapped to /wpresources/[assembly_name].

The workaround to this is to use the ClassResourcePath property. The SDK advises use to "Use the path returned by the ClassResourcePath property to prefix resource URLs for the browser to fetch."

The gotcha comes in when you try to access this external resource directly from disk when the context is a sub-site. Since the file is in a directory, I have always grabbed the file like this:

Dim resourceURI As URI = New Uri(ClassResourcePath)
Dim partResourcePath as String = Context.Server.MapPath(resourceURI.AbsolutePath)
.
.
.
Dim resourcePath as string = Path.Combine(partResourcePath, "somefile.xsl")
Dim trn As XslTransform = New XslTransform
trn.Load(resourcePath)

What is happening, however, is that the sub-site address is included in the ClassResourcePath. This is mapped correctly when requesting the file via the URL, but not whem mapping the path to a physical directory.

When using ClassResourcePath, be sure to use http to access the resource.

Thursday, January 27, 2005 4:16:30 PM (Central Standard Time, UTC-06:00)  #    Comments [0]  | 
# Friday, January 21, 2005

I've left pieces of this here and here. But perhaps a little code would help. :)

Public Class MyWebPart
Inherits Microsoft.SharePoint.WebPartPages.WebPart

Private Const TRACE_CLASS_ID As String = "MyWebPart"

Protected Overrides Sub RenderWebPart(ByVal output as System.Web.UI.HtmlTextWriter)
Dim TRACE_CATEGORY As String = TRACE_CLASS_ID + "RenderWebPart"

Try
Context.Trace.Write(TRACE_CATEGORY, "Trying something")
' Do something here

' pretend there is a variable
Context.Trace.Write(TRACE_CATEGORY, "variable value: " + variable)

output.Write("you html code goes here")

Catch ex As Exception
Context.Trace.Warn(TRACE_CATEGORY, ex.ToString)
End Try

End Sub

Friday, January 21, 2005 12:35:56 PM (Central Standard Time, UTC-06:00)  #    Comments [0]  | 
# Thursday, January 20, 2005

Tariq has a post that details how to create a tabstrip (like a meeting workspace) using a list as the data source.

Thanks Tariq!

Thursday, January 20, 2005 11:02:32 AM (Central Standard Time, UTC-06:00)  #    Comments [0]  | 
I'm testing a post on the new dasBlog 1.7
 
Please disregard
Thursday, January 20, 2005 10:25:13 AM (Central Standard Time, UTC-06:00)  #    Comments [0]  | 

Log Parser 2.2

Log parser is a powerful, versatile tool that provides universal query access to text-based data such as log files, XML files and CSV files, as well as key data sources on the Windows® operating system such as the Event Log, the Registry, the file system, and Active Directory®. You tell Log Parser what information you need and how you want it processed. The results of your query can be custom-formatted in text based output, or they can be persisted to more specialty targets like SQL, SYSLOG, or a chart.

Most software is designed to accomplish a limited numer of specific tasks. Log Parser is different... the number of ways it can be used is limited only by the needs and imagination of the user. The world is your database with Log Parser.

This is an update to the tool I mentioned before. (Two years ago!) But, since it still gets hits from the search engines, it's worth updating the post.

Thursday, January 20, 2005 8:14:48 AM (Central Standard Time, UTC-06:00)  #    Comments [0]  | 
# Wednesday, January 19, 2005

dasBlog, the software used to run this blog, has been updated to v1.7. I have upgraded my site, so please let me know if you see anything amiss. This new version includes a Captcha control for comments, which helps to block bots from posting comment spam. I hope that this is not too much trouble for you. Also, my customized theme was not working so well, so I went back to the default until I can figure out what's up.

Thanks for your patience.

Wednesday, January 19, 2005 10:45:44 AM (Central Standard Time, UTC-06:00)  #    Comments [0]  | 
# Friday, January 07, 2005

Brian Goldfarb is soliciting help about what type of MasterPage templates to build. (He doesn't say so, but I assume he means that these would be shipped with ASP.Net 2.0 or at least downloadable.)

My response in his comments:

I think have at least a few "ready-to-go" pages would be helpful. Like SharePoint services -- some templates are full of web parts, others are just shells.

Friday, January 07, 2005 1:27:44 PM (Central Standard Time, UTC-06:00)  #    Comments [0]  | 
# Wednesday, January 05, 2005

Mom

The most powerful force in this universe.

John Buccigross; ESPN.com; January 2, 2005

Wednesday, January 05, 2005 3:29:34 PM (Central Standard Time, UTC-06:00)  #    Comments [0]  | 

I wrote about and dismissed SmarterStats for web server log analysis. It's been almost a year, so a little update is in order.

I have licensed and installed the enterprise version of this tool. With the web farm deployed (read the Sharepoint category) and some legacy web servers, SmarterStats became a very attractive option.

For those with less demanding needs, Microsoft has a KBase article that shows how to use the bulk copy program (bcp) to load the log files.

Update: KB Article discovered via John West

Wednesday, January 05, 2005 3:26:50 PM (Central Standard Time, UTC-06:00)  #    Comments [0]  | 
# Monday, January 03, 2005

UPDATE: John points out “It should be noted that when you change the setting to CT with UIiB, an automatic Full or Incremental (depending upon the presence of a timestamp column) is executed to re-sync the table data with the FT Catalog.“  I missed this when I posted, but new visitors should be aware of this. Thanks John!


John Kane came across my post on the forums at Joel on Software about full-text indexing on SQL Server. I suggested that I could post a script that sets all of the tables in an index to background change tracking, but I never did make that post.

So, here is a T-SQL script that will check every table in every catalog in the current database:

DECLARE @FTCatID smallint, @FTPath nvarchar(260), @FTStatus int
DECLARE @FTName sysname, @FTNbrTbls int DECLARE @csr_FT CURSOR

DECLARE @FTTOwner sysname, @FTTName sysname, @FTTIndex sysname
DECLARE @FTTColid int, @FTTActive int, @FTTCat sysname
DECLARE @csr_FTT CURSOR

-- Get all the catalogs in the current database
EXEC sp_help_fulltext_catalogs_cursor @csr_FT OUTPUT
FETCH NEXT FROM @csr_FT INTO @FTCatID, @FTName, @FTPath, @FTStatus, @FTNbrTbls
WHILE (@@FETCH_STATUS = 0)
BEGIN

-- Get all the tables in this catalog

print @FTName
EXEC sp_help_fulltext_tables_cursor @csr_FTT OUTPUT, @FTName
FETCH NEXT FROM @csr_FTT INTO @FTTOwner, @FTTName, @FTTIndex, @FTTColid, @FTTActive, @FTTCat

WHILE (@@FETCH_STATUS = 0)
BEGIN

print ' ' + @FTTName
EXEC sp_fulltext_table @FTTName, 'Start_change_tracking'
EXEC sp_fulltext_table @FTTName, 'Start_background_updateindex'

FETCH NEXT FROM @csr_FTT INTO @FTTOwner, @FTTName, @FTTIndex, @FTTColid, @FTTActive, @FTTCat

END

CLOSE @csr_FTT

DEALLOCATE @csr_FTT

FETCH NEXT FROM @csr_FT INTO @FTCatID, @FTName, @FTPath, @FTStatus, @FTNbrTbls END

CLOSE @csr_FT
DEALLOCATE @csr_FT

 

If your server is setup like mine, you might have multiple databases on the server. If you want to run the above script on all the databases, here is a VBScript to do so:

dim oServer, oDB, oFS, oFile
dim sCmdBatch

Set oFS = CreateObject("Scripting.FileSystemObject")
Set oFile = oFS.OpenTextFile("FT_change_tracking.sql")
sCmdBatch = oFile.ReadAll

Set oServer = CreateObject("SQLDMO.SQLServer")

WScript.Echo "Connecting..."
oServer.LoginSecure = True
oServer.Connect "servername"

On Error Resume Next

For Each oDB in oServer.Databases
    WScript.Echo "Database: " & oDB.Name
    oDB.ExecuteImmediate sCmdBatch
Next

Monday, January 03, 2005 3:22:39 PM (Central Standard Time, UTC-06:00)  #    Comments [0]  | 
Search

Powered by: newtelligence dasBlog 2.2.8279.16125

The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2010, Paul Schaeflein

Send mail to the author(s) E-mail