Friday, May 07, 2004

Searching Indexing Services with ASP.NET and C#

So I have a project that requires we have a mini site search. And being that I have written the whole site in ASP.NET/C#/XML/XSL I didn't want to have to go back to classic ASP for search. I did some searching online and found a really good post on using ASP.NET with Indexing Services. The article/post "Query the Indexing Service with Ixsso and ASP.NET" covered the issue really well. However it was written in VB. So of course I needed a C# version of it, so I just translated the VB stuff to C# and voila!.

private void searchIndexing(string strValue)

{

try

{

CissoQueryClass Q = new CissoQueryClass();

CissoUtilClass util = new CissoUtilClass();

OleDbDataAdapter da = new OleDbDataAdapter();

DataSet ds = new DataSet("IndexServerResults");

Q.Query = strValue;

Q.SortBy = "rank[d]";

Q.Columns = "vpath, filename, rank, characterization";

Q.Catalog = "query://contentserver/catalogname";

Q.MaxRecords = 1000;

util.AddScopeToQuery(Q,"\\","deep");

Q.LocaleID = util.ISOToLocaleID("EN-US");

da.Fill(ds, Q.CreateRecordset("nonsequential"), "IndexServerResults");

DataGrid1.DataSource = ds;

DataGrid1.DataBind();

 

}

catch(Exception f)

{

lblError.Text = f.Message.ToString();

}

}

Just make sure you add a reference to the IXSSO COM Object in your project and away it goes!

 

Thursday, May 06, 2004

Things I've learned about ASPNET (the local user account for ASP.NET)

Well, I have been trying to trackdown an incredibly irritating issue with my ASP.NET v1.1 code not running on one of our w2k (windows 2000) servers. I think the root cause of it all has to deal with the fact that this box runs OWA (Outlook Web Access) and OWA doesn't play well will other. So here is the run down. In the machine.config , node processmodel where use name says "machine" it is using the ASPNET local user. For the most part this user has access to everything it needs because it is in the Group user. (I know a user in the user group... a little redundant). However there are some instances, depending on patches and services packs where this user doesn't get the correct NT users permissions. This table from Microsoft really helped.

Table 1. Required NTFS permissions

FolderRequired PermissionAccountComments
C:\WINNT\Microsoft.NET\
Framework\<version>\
Temporary ASP.NET Files
Full ControlProcess and fixed impersonation accountsThis is the ASP.NET dynamic compilation location. Application code is generated in a discrete directory for each application beneath this folder.
The tempdir attribute on the <compilation> element can be used to change this default location.
C:\WINNT\tempRead/Write/DeleteProcessLocation used by Web services to generate serialization proxies.
Note that the Delete permission is set using the Advanced button on the Security page of the Windows Explorer folder properties dialog box.
Application folderReadProcessThe location of your Web application files (that is, your application's virtual root directory: for example, c:\inetpub\wwwroot\webapp1).
By default, the Users group has the appropriate access rights.
%installroot% hierarchy
(C:\WINNT\Microsoft.Net\Framework\v1.0.3705)
ReadProcess and fixed impersonation accountsASP.NET must be able to access .NET Framework assemblies.
By default, the Users group has the appropriate access rights.
C:\WINNT\assemblyReadProcess and fixed impersonation accountsThis is the global assembly cache. You cannot directly use Windows Explorer to edit ACLs for this folder. Instead, use a command Windows and run the following command:
cacls %windir%\assembly /e /t /p domain\useraccount:R
Alternatively, prior to using Windows explorer, unregister shfusion.dll with the following command:
regsvr32–u shfusion.dll
After setting permissions with Windows explorer, re-register shfusion.dll with the following command:
regsvr32 shfusion.dll
Web site root:
C:\inetpub\
wwwroot or the path that the
default Web site points to
ReadProcessASP.NET reads configuration files and monitors for file changes in this folder.
C:\WINNT\system32ReadProcessFor system DLLs loaded by the Framework.
Parent directories of contextList Folder/ ReadProcessFor file change notifications and the C# compiler.

Wednesday, May 05, 2004

It's 3AM

Well, It's 3 AM. I don't know why I am not sleeping away, dreaming of being on a beach with my beautiful Wife drinking some tropical drink with a little umbrella in it. Instead I am ftping a xml parser to the server and installing that. My beautiful Wife and I even talked about this. I want to be a good sleeper. It is on my goals list. Top five even, but I'm awake and working away. And working on server configurations at that. Now that is boring stuff. People have decided to have elective surgery over having to work on server configurations. But here I am plugging way at it.

Tuesday, May 04, 2004

A Weekend with VAM

So this weekend I worked a lot. Come to find out that one of my applications that was ASP.NET Validators had NO client-side validation for netscape, mozilla and opera. Of course there was no mention of this deficience in the .NET framework documentation. This explains the ghost problems that I have been chasing for close to a year with this application. That being the case I need to fix it and fix it quick. That is where VAM comes in. VAM is a fantastic validation framework that Peter Blum has put together. It is completely cross-browser and cross-platform compatible validation. Simply put is it brilliant. Peter has done a great job of documenting the product. So this weekend armed with the documentation and the new validation framework, I went to work at rewriting the application the take advantage of VAM and get back a little self respect. (It's really hard to realize that something you wrote, didn't work as you planned for a year. It's kind of humiliating).

Between learning the new framework and writing some code the make the application better than it was. (I know a year more of .NET then I did when I wrote it) I spend about 15 hours this weekend on it, but I am much happier with the product. Interesting enough, some of the code from a year ago seemed a little sloppy, and the validators thought so too. Like I would have two buttons, one for each mode the page would have and then I would hide or show the button depending on the mode. Well, that is a little redundant. So I rewrote the pages with one button that would change dependingo on the mode. It all goes back to KISS (Keep It Simple Stupid). Why would I need two buttons when one will do the job. I did a lot of clean up like that , that I feel will make the application run quicker. The less controls that have to be rendered the faster the ASP.NET will run.

Well, this weekend wasn't all work. My Beautiful Wife vowed to get me way from my squareheaded girlfriend (my laptop). So sunday afternoon/evening, we picked up Mom and Dad and headed down to the happiest place on earth. We decided to go in the other disneyland park. It was a blast. Sunday was very warm, so everyone had apparently decided to skip going to the park that mouse built. I don't thiink I had ever seen the park so empty. We walked on to "Soarin' over California", checkout the Grand Californian, got drenched on "Grizzly Rapids", had some wine and dine at the Golden Vine. It was all so nice, and it cool down perfectly. (Especially after the soaking we got on Grizzly Rapids) Then Dad and I got to check out the new Tower of Terror Ride! I have to say that it is first rate. We both thought that it was a lot of fun. A good sunday afternoon.