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]  | 
# Wednesday, January 12, 2005

Received the following email today:

We have been working on customizing the Training page. On that page (doc library) we're going to store all our training materials, and we'd like to store our Camtasia "movies" there as well. These movies are annotated screen captures of the steps to perform various tasks. Once recorded and annotated, they are stored as an .exe file that includes the Camtasia viewer, which is the optimal way of doing this.

We discovered that we cannot put an .exe file on the page (in the document library). Is this something that can be changed for our page?

I know you're thinking “that's a nice can of worms you have there.”

The technical answer is yes. Refer to the admin guide.

I would love to hear any arguments in favor of allowing this. This is a completely internal site. The server is controlled by the corporate IS Department. The WSS site in in the Intranet Zone.

My point is that users will develop habits regardless of the location of the server. Telling them that it is OK to download and run this file because it is on our server will lead to them thinking it's alright do this elsewhere.

I welcome your comments.

Wednesday, January 12, 2005 1:29:41 PM (Central Standard Time, UTC-06:00)  #    Comments [0]  | 

I (finally) got around to opening the new Scot Hillier book Advanced SharePoint Services Solutions. Right out of the gate, he describes CAML in great detail. Very nice.

He mentions in the introduction that this is not a beginners book, and rightly so. In the first two chapters, there is just a little introduction and then lots of detail. For example, the web services chapter dives right into create a SOAP request with spending time explaining SOAP. This is perfect for me!

The last half of the book discusses other related Microsoft products: IBF, BizTalk, MSMS. Since I've not used those too much, I haven't spent time in those chapters. But the first half of the book has been very helpful.

You can view the table of contents at the Apress site.

Wednesday, January 12, 2005 11:15:35 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]  | 
Search

Further Reading...

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 2008, Paul Schaeflein

Send mail to the author(s) E-mail