break
Oct 27

In my quest to deploy an application to a Windows 2003 Server, I got another error:

“Access is denied.
ASP.NET is not authorized to access the requested resource. Consider granting access rights to the resource to the ASP.NET request identity. ASP.NET has a base process identity (typically {MACHINE}\ASPNET on IIS 5 or Network Service on IIS 6) that is used if the application is not impersonating. If the application is impersonating via , the identity will be the anonymous user (typically IUSR_MACHINENAME) or the authenticated request user.

To grant ASP.NET write access to a file, right-click the file in Explorer, choose “Properties” and select the Security tab. Click “Add” to add the appropriate user or group. Highlight the ASP.NET account, and check the boxes for the desired access.”

That description is really nice, but it didn’t solve the problem. Not even close. You need to go to the Event Viewer, System, and in there I found a DCOM error that said:

“The application-specific permission settings do not grant Local Activation permission for the COM Server application with CLSID
{361146D5-C2AC-30BE-841C-385F740A88FC}
to the user MLIDDOMAIN1\user SID (S-1-5-21-7223768-1134175843-1648912389-106998). This security permission can be modified using the Component Services administrative tool.”
. In reality, this is the error you are dealing with.

Solution:

Go to start -> run and then type “regedit”. In the registry editor go to edit and search for: “361146D5-C2AC-30BE-841C-385F740A88FC” (in my scenario). You should find that string and a “value data” (in my case sqlHelper). When you find the value data, look for that component in the Component Services. To get to the component services, go to start -> run and then type “dcomcnfg”.

In the component services, expand component services -> computers -> my computer -> com+ applications. In my case the component sqlHelper was here. I did a right click -> properties. In the security tab “UNCHECK” where it says “Enforce access checks for this application”.

The error should be gone!!!

Oct 27

I was deploying an application in a Windows 2003 Server and got the following error:

“The page cannot be found. HTTP Error 404 – File or directory not found.
Internet Information Services (IIS)”

I went to IIS, and looked for the “Web Service Extensions” section. I made sure the following is allowed:

  • Active Server Pages
  • ASP.NET v1.1.4322

In my case it was in a “prohibited” status. After it was in an “allowed” status, this error went away.

Jun 7

I have seen this problem in the following scenario: You type some input in a textbox, you hit enter and when you are expecting the retrieve/submit button (based on the wording you are using) to return a result set, instead you get this pop-up:

If this is your scenario, I have a recommendation for you: Use an asp.net panel, and assign a DefaultButton to your panel ( usually the name of your retrieve/submit button )
For example:
<asp:panel id="Panel1" runat="server" defaultbutton="btnRetrieve">
If you have a different solution, with a different scenario, let me know.

Jan 13

Is debugging becoming a slow process? Lately, the first time I try to debug an ASP.NET project, it doesn’t start debugging smoothly. After 3 or 4 minutes I receive the following message:

“Unable to start debugging on the web server. The web server did not respond in a timely manner. This may be because another debugger is already attached to the web server”.

This problem may have many solutions. I fixed this problem by removing all my breakpoints from the project. There are 2 ways of doing this:

1- Press “Ctrl + Shift + F9″

2- On the menu bar press “Debug” then select “Delete All Breakpoints”

If you find another way to solve this let me know.

Feb 13

When you go to Yahoo, if you start typing in their web search, after you type several words, you end up with a window that has several options according to the search string you just entered. I was trying to simulate that effect in an asp.net webpage.

To do this I decided to use the ASP.NET AJAX TOOLKIT. I am using Visual Web Developer 2008 Express to do this, I created a new website, and started working from here.

To accomplish this you will need to:

1- Add the AjaxControlToolkit.dll to your project(Add reference -> Browse tab ). When you download the tookit you can search for this dll, and you should be able to find it.
(I found mine in this path: Visual Studio 2005\Templates\ProjectTemplates\Visual C#\AjaxControlExtenderProjectCS\AjaxControlToolkit.dll)
2- Add a webform to your project
3- Add a web service to your project
4- Add a style sheet to your project

The Webform:
I will proceed to explain several parts of the webform

Before the HTML you need to register the Ajax Control Toolkit custom control.
<%@ Register
Assembly=”AjaxControlToolkit”
Namespace=”AjaxControlToolkit”
TagPrefix=”ajaxToolkit” %>

Don’t forget to add the style sheet we are using.
<link href=”StyleSheet.css” rel=”stylesheet” type=”text/css” />

Inside the form I have the following:
First, I start adding a toolkit script manager:
<ajaxtoolkit:toolkitscriptmanager runat=”server” id=”ScriptManager1″/>
If you don’t do this you might get an error that says “The control with ID ‘AutoComplete1′ requires a ScriptManager on the page. The ScriptManager must appear before any controls that need it.”. The reason you need it (as I understand it) is that the toolkit script manager merges multiple javascript scripts into one file, which is downloaded at runtime.

Then, you need a textbox, which is where your search is going to be typed.
<asp:textbox runat=”server” id=”txtInput” width=”300″/>

Of course, you need to add in the form the ASP.NET AJAX AutoComplete Extender. According to the asp.net webpage this extender:”can be attached to any TextBox control, and will associate that control with a popup panel to display words that begin with the prefix typed into the textbox.”. This is how the extender looks in my form:
<ajaxToolkit:AutoCompleteExtender
runat=”server”
ID=”AutoComplete1″
TargetControlID =”txtInput”
ServiceMethod=”GetCustomersContactTitle”
ServicePath=”WebService.asmx”
MinimumPrefixLength=”2″
CompletionInterval=”1000″
EnableCaching=”true”
CompletionSetCount=”20″
CompletionListCssClass=”flyout-background”
CompletionListItemCssClass=”flyout-item”
CompletionListHighlightedItemCssClass=”flyout-item-hover”>
</ajaxToolkit:AutoCompleteExtender>

This is what the webform needs, nonetheless, this is very basic, because my purpose is to show how this works, and that you can also understand what everything means.

Now, I am going to write about the two most important parts of the webservice :

First, make sure this line is commented when you add your Webservice. This line needs to be uncommented, since you need to call the webservice from your webform.
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
[System.Web.Script.Services.ScriptService]

Last but not least, you need a method that returns the data to be displayed. My method basically gets the ContactTitle Column in the Customers table which is located in the Northwind database. I used this database since it is available to everyone. The AJAX AutoComplete Extender requires that the method that you use to display data, matches the following signature: a method that returns an array of strings, and has two parameters, which is the prefix the user just entered, and the amount of records to be displayed.


[WebMethod]
public string[] GetCustomersContactTitle(string prefixText, int count)
{
List<string> items = new List<string>(count);
DataSet ds = new DataSet();string connectionString = "Data Source=(local);Initial Catalog=Northwind;Integrated Security=SSPI;";
using(SqlConnection connection = new SqlConnection(connectionString))
{
string sql = "SELECT ContactTitle FROM Customers WHERE ContactTitle LIKE '" + prefixText + "%'";
SqlDataAdapter adapter = new SqlDataAdapter();
adapter.SelectCommand = new SqlCommand(sql,connection);
adapter.Fill(ds);
}
foreach (DataRow dr in ds.Tables[0].Rows)
{
items.Add(dr["ContactTitle"].ToString());
}
return items.ToArray();
}

Finally, the stylesheet, to have a better understanding on the CSS Classes I would recommend that you play with them, so you have a better understanding on what they do. Nonetheless, I provided a description of what they do.

This class is going to be applied to the completion list flyout.
.flyout-background {
border: 1px solid #009;
list-style-type: none;
margin: 0px;
background-color: #FFFFFF;
text-align: left;
}

This class is going to be applied to an item in the AutoComplete list flyout.
.flyout-item {
color: #FF0000;
}

This class is going to be applied to a highlighted item in the AutoComplete list flyout.
.flyout-item-hover {
background-color: #66FFFF;
}

This is the final result:

Here’s a copy of my files

If you have any comments just let me know.

Nov 6

I am using Windows Server 2003 for some development on some ASP.NET 2.0 projects. However, when I tried to compile my first project I had an error that said:

“This product requires ASP.Net web service extensions to be enabled in Internet Information Services (IIS)”.

I went into my Administrative Tools-> Internet Information Services (IIS) Manager, and I didn’t find my Web Service Extension for ASP.NET 2.0. Consequently, I had to install asp.net (2.0.50727) WebService Extensions.

In order to do this, I used a command prompt and went to:

C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727.

In that directory I typed:

aspnet_regiis -i

After this you should see in your command prompt something that says like this: “Start installing ASP.NET (2.0.50727)”. After the extensions are installed you should see something like this: “Finished installing ASP.NET (2.0.50727)”. At this point, this error should be solved, and your ASP.NET 2.0 WebService Extensions should be installed.