Sunday, January 13, 2008

DotNetNuke No Image on Newsletter Issue Fix Found

This is the issue that has been bugging me for a few years, but finally there is a working solution.

Symptom:

So you go to the Newsletter module, incorporate an image or two in the newsletter using the "image" tool that comes with the default editor (FTB Editor). Much to dismay, the images do not show up in email.

Cause:

DotNetNuke had this nasty URL rewrite stuff built into it that if an URL is local to the installed directory of DotNetNuke, it will strip the root URL. This will work for contents that are within the site, but in email it won't work.

Fix:

I have discovered this on DNN 4.8.0, but I think somewhere around DNN 4.5 or later this change was made. Unfortunately if you are using a much older version of DNN, there is not much hope except for working this around with domain remapping technique, also provided in this article.

Steps:
  1. Go to the Newsletters Module, just as if you are writing a new newsltter
  2. Under the bottom of the editor panel, you should see "Show Custom Editor Options." Click that.
  3. A configuration dialog box will pop up. If it does not, check your pop-up blocker and try again.
  4. Under the Settings Type, select Module
  5. Click the + for "Other editor options"
  6. Check mark the"Full image path" option.
  7. Scroll down and select the pull down menu for Apply Custom settings to "Module" then click the Apply link.

Workaround for Older DNN Sites

The URL rewrite stuff does not apply to the URLs that do not match what's in the Portal Alias, so what I used to do was to map another domain on top of the existing domain and then I would go into the HTML and change the root domain for all included image URL before sending out the email. For example, for my site StokeMaster.com, I also mapped StokeMaters.com. I would cut the HTML code after editing the newsletter to a text editor on a local machine, do a global replace of StokeMaster.com with StokeMasters.com and re-paste back then send out email. A major extra work, but it does work.

Saturday, December 08, 2007

ASP.NET 2 Pop-Up Calendar Field Alternate

Problem:

This is a very common thing we all do. Ask the user to enter a date or a range of dates into a web form. The best way to ensure the format is to use the calendar control that comes with the ASP.NET framework. But these calendar controls are so huge that you'd only want to bring in to the page only when it is needed. There are many solutions offered on various web sites about how this is done.

The problem in most of the solution, at least for me, is that you need to understand or deal with JavaScript to open another window, pass some parameters to it, pass back more parameters and then finally to fill out the main form.

Many of us do not do web programming day in and day out and rather not have to deal with JavaScript (for that matter avoid any programming languages that start with a letter "J"). While he JS technique is definitely more elegant, we can hit the middle ground.

Solution:

One alternate solution that I came up with to take advantage of MultiView control. It is actually quite neat that you can basically create "layers" of panels that they call a View and expose any panel at your will. So for example in my case, I display a grid list of all previous surf stuff orders from past 30 days. When I need to ask for the date range, I have two calendar controls on another view asking for the first and last days, and I will bring that "forward." As soon as the second calendar control (for the last day) is clicked, I can trap the event for the Selected Date Changed, collect the new pair of dates from the controls, bring the view with the data grid again.

It is quite easy to do, just set whichever the view you would like to show in the MultiView control, and I did not touch a line of HTTP source code to do this.

Time Took To Figure Out

Once I've realized this possibility, it took me just about 30 min to confirm that this will work for me.

Friday, December 07, 2007

ASP.NET GridView Prevent Automatic Binding Upon Page Startup

Problem:

I have set up the ObjectDataSource from the Table Adapter using the Visual Studio 2005 in Design Mode. Now the page comes up fine, but I now want to add some query parameter filed, and do not want to show the grid right when the page comes up.

Fix:

There may be many ways of fixing it, but so far this technique is working well for me.
  1. Go to the ObjectDataSource's property and switch to the Events view (the lightening bolt icon on top).
  2. Double click in Selecting event so that the VS will create an event handler.
  3. Go to the event handler.
private bool quiversGridEnabled = false;


protected void ObjectDataSourceQuives_Selecting(object sender,
ObjectDataSourceSelectingEventArgs e)
{
if (quiversEnabled == false) e.Cancel = true;
}

At another point in the code, for example, when the button to query a new quiver is pressed then I would set quiversGridEnabled to true, then subsequent calls to Bind() to the Gridview will show the data based on the query.

Time To Find The Solution:

It took about an hour to find out how I'd do this. If there are better and cleaner ways of doing it, be sure to comment on this entry.

Sunday, December 02, 2007

SQL 2005 Find Out Who Are Connected

Problem:

I want to provide a list of currently connected SQL clients on my asp.net based web page, like the version of Activity Monitor that comes in the SQL Management Studio.

Solution:

The information are in the following queriable objects. For me, sp_who is good enough as I just need to list who are connected in my application monitor web app.
  • exec sp_who
  • exec sp_who2
  • select * from master..sysprocesses

and finally this is supposed to give you the same list as what you see in the Activity Monitor (I did not try).

DECLARE @CMD VARCHAR(8000) DECLARE @ID int
SET @ID = @@SPID SET @CMD = '
EXEC sp_MSset_current_activity ' + CAST(@id as varchar) + '
SELECT * FROM ##lockinfo' + CAST(@id as varchar) + '
SELECT * FROM ##procinfo' + CAST(@id as varchar)
EXEC (@CMD)


Time Saved:

This information is either too obvious to DBAs or such that query to Google or Live does not provide an immediate answer. Took me about 30 min to finally found out. The keyword to search is "Activity Monitor"

Tuesday, November 27, 2007

SQL 2005 Mirroring Witness Connection Does Not Estalbish on one node

Symptom

When you've added an Witness Server to the mix, and you start to get the following error message in the Application Log. You are running all of the service under a specific domain user and everything runs but this. The Database Mirroring Monitor shows that Witness Connection is OFF (red X) on only one server.

Event Type: Information
Event Source: MSSQL$XYZ
Event Category: (4)
Event ID: 28048
Date: 11/27/2007
Time: 6:13:38 PM
User: N/A
Computer: SQLServer2
Description:

Database Mirroring login attempt by user 'mydomain\sqlservice.' failed with error: 'Connection handshake failed. The login 'mydomain\sqlservice' does not have CONNECT permission on the endpoint. State 84.'. [CLIENT: 10.1.2.3]

Cause

Root cause is really unknown. Probably a bad sequence of installing and configuring database mirroring. But the immediate cause that can be fixed is that the computer node which you have seen the event log is not granting the Connect permission on the Mirroring endpoint object in the securables for the log in account mentioned.

Fix

This is an issue of the Witness Server unable to establish a connection to the Principal or Mirror Server (whichever is broken). I was able to fix this by;

  1. Start the Microsoft SQL Server Management Studio
  2. Connect to the database server that has an issue.
  3. Go to the Security folder
  4. Add the login name that is indicated in the Event Log. In my example MYDOMAIN\sqlservice
  5. Select the account you've just added and open its property (i.e., right click it)
  6. Select Securables
  7. Press Add...
  8. Select (leave it selected as) Specific Objects...
  9. Perss OK
  10. Under Select Objects dialog box press Object Types...
  11. Check Endpoints
  12. Press Browse...
  13. Add [Mirroring] object.
  14. Once back in the main property window, check mark Grant
That has fixed it!

Total hours to figure this stuff: 2 hours.

Monday, November 26, 2007

IIS 6 - "Page Cannot Be Found" When Running .NET Pages

Problem

I have downloaded an ASP.NET application, made sure that the directory property is correct, set the Web Application, the documents contain .aspx and application settings are pointing to correct version of .NET framework.

When I point to the page in the application directory, for example "Default.aspx", the browser comes back and says "Page cannot be found" Even though if you put in index.html file there with some simple test HTML in it, it works.

I have tried to re-install .NET framework...

I have even tried to run C:\Windows\Microsoft.NET\Framework\v2.0.50727\aspnet_regiis.exe /i


Cause

In Windows Server 2003, ASP.NET may be turned off by default, even if you have done bunch of other stuff that I have tried.

Solution

Go back to your computer management and open the Internet Information Service node. You will find one last folder in there that is called Web Service Extensions. You will likely to see that ASP.NET v.2.0.50727 (or whatever the latest version) is in Prohibited state.

As soon as you Allow this, then your pages will run without a problem.

This solution also fixes the problem of ASP.NET tab not appearing in the IIS Web Site properties.

Time took: About 3 hours to find this issue. Whey don't they come up by default!

Wednesday, November 14, 2007

SQL Server Database Mirroing Cannot Establish A Witness

Problem:

I spent about two days on this issue. I could establish a Principal and Mirror pair with the SQL Server 2005, but when an Witness server was added in the mix, the witness could not establish.

I have gotten errors like "Cannot find the server at mirror.xyz.com" and "Alter Database Failed..."

Answer:

You should go through the article on MSDN http://msdn2.microsoft.com/en-us/library/ms189127.aspx to make sure that you did not botch up any other stuff.

The key to this are the following,
  • The mirroring operation is very very sensitive to DNS, if there is anything wrong with it, it won't work.
  • The fact that you can "talk" to the mirror and the principal using all aliases is not a sufficient test. Go to each machine (e.g., the mirror and the witness) involved and make sure that all full and DNS alias names can be resolvable to the (identical) IP address and that you can ping the servers with ALL of the known names. If this does not work then you should "hard wire" all the names and addresses in the local machine's C:\Windows\System32\Drivers\Etc\Hosts file.

What Made This Difficult:

In my specific sitaution, there were couple of DNS aliases for all of the servers, and the host name appeared in all different variety of names while confugiring the mirror. As it turns out that having various names is not actually an issue, but the DNS configuration on the TCP/IP control panel was all slightly different causing one server for not being able to find the server name.

Total Time Saved:

You will save at least one day or more of your time by debugging the DNS first.

Thursday, October 25, 2007

.NET DateTime Objects Does Not Compare Correctly

Environment: C#

Symptom:


You have parsed a date time string and made a DateTime object, then you wanted to compare that with current time using DateTime.Now, but it does not work.

DateTime t1 = DateTime.Parse("27 October 2007 10:27");

if (t1 > DateTime.Now) { /* do something */ }

Cause:

The parsed DatTime object has the Kind attribute set to UNKNOWN while DateTime.Now is set to LOCAL. Comparison between the two will not work as expected.

Fix:

There may be other ways of doing this, but here is the one that made my code to work.

DateTime t1 = DateTime.Parse("27 October 2007 10:27");
t1 = DateTime.SpecifyKind(t1, DateTimeKind.Local);
if (t1 > DateTime.Now) { /* do something */ }


Time Wasted:

Took me about 2 hours to figure out what is exactly going on and how to fix it.

Monday, October 15, 2007

Unable to Load DLL Error

Symptom:

You built an application using Visual Stuido 2005, you also have a Platform Invoke code so that your managed code can call unmanaged code stored in your platform invoke DLL, and in order to test it on another machine, you copy the bin/debug folder there. The test machine does not have the Visual Studio 2005.

As soon as you run the program, and when your code calls the platform invoke code the following error message occurs,

Unable to load DLL 'Some.DLL': This application has failed to start because the application configuration is incorrect. Reinstalling the application may fix this problem. (Exception from HRESULT: 0x800736B1)

Possible Cause and Fix:

This article is still being completed. But here is what I have figured out so far:

Apparently, when you build a code that includes a platform invokaction code (i.e., calling a C++ library), there is a run-time (CRT) code to be included, and if you are doing this on a debug code then there are some very complex issues.

There is one person on the web that solved this issue by using the release build. I am going to try that approach.

If that's not what you want, here is a detailed information about this.

http://www.codeproject.com/cpp/vcredists_x86.asp#Troubleshooting

(This article will be updated further as I find the final solution.)

Saturday, September 29, 2007

CISCO ASA and Getting Mac/Windows L2TP To Work

Symptom:

You used the VPN Wizard in CISCO ASA's ASDM to create an L2TP configuration, but it does not work.

You look at the ASA Log and it says something to the effect that no acceptable SAs.

What Fixed:

Know that the Mac and PC will connect through the DefaultRAGroup therefore if you are doing a pre-shared key, it must be set right there. If you are not going through Phase 1, check that first.

If you are going through the Pase 1 then you are likely that the TRANSPORT mode of IPSec is not included in your Dynamic IPSec policy.

Check the following,

crypto dynamic-map Extranet_dyn_map 20 set transform-set TRANS_ESP_3DES_SHA ESP-AES-256-MD5 ESP-3DES-SHA

Finally if you are using the user account with the ASA itself, then the user password must be encrypted using nt-encrypted keyword. I would just telnet to the ASA and type that in. I am not sure if you are using both the CISCO client and L2TP, both ASA native mode of encryption and the nt encryption are allowed, so I have created a second user name for the purpose of logging on via L2TP.

username bozo password xyzzy nt-encrypted

Total Time To Figure Out This Issue

Approximately 4 hours.

Tuesday, September 25, 2007

Microsoft IIS SMTP Server Does Not Relay or Send Emails

Symptom:

You've installed the SMTP server (Default SMTP Virtual Server) as a part of the IIS on Microsoft Windows Server 2003, but nothing get relayed.

What Fixed:

The no hosts, including the local ones are by default not being relayed out of the box. You need to go to Default SMTP Virtual Server Properties, go in the Access tab and Press the Relay... button.

You should grant the relay permission to the server or all the IP addresses in your local network.

Total research fix time: About 30 minutes.

CISCO ASA Error construct_ipsec_delete(): No SPI to identify Phase 2 SA!

 This article is the most popular article on this blog as of July 2012.

Another one of those very cryptic CISCO log message. I guess these messages deserve to be cryptic, since my IOS code has a lot of "crypto" all over the place ;-)

Symptom:

When configuring for Site-to-Site VPN network, the IKE negotiation (Phase 1) works but Phase 2 results in a message like
  • construct_ipsec_delete(): No SPI to identify Phase 2 SA!
What Fixed It:

It appears that this occurs when there is a significant mismatch in the VPN Tunnel IPSec configuration parameters. IPSec is also know as Phase 2. If you have come this far in your connection then Phase 1, or the IKE step is complete so do not go down the pass of "fixing" the Phase 1, for example, Shared Key mismatch. You are OK there, and focus on fixing this Phase 2 issue.

If you are using like me the ASDM, this information is in VPN->IPSec->IPSec Rules section.
  • Be sure that the Network Address and Netmasks of End Points are properly set on both ends. For your end this is found at IPSec->IPSecRules->Traffic Selection. You could also be using Static NAT, so check to make sure that the NAT tables are correct. This is especially important if you are NATTing to external routable addresses to avoid non-routable IP address conflicts (this is a very very advanced topic and I don't even know what I am talking about so if this does not make sense, you do have to go to a CISCO professional for help. I am just a surfer with this job dropped on my lap.)
  • Speaking of the NAT, you are likely that you have NATTed your inside address pool to a set of private addresses you have. If that is the case, then you DO have to make a NAT exception. The VPN wiz does that, but if you add another host in the same tunnel then you cannot use the Wiz any more so you'd forget this. Simply look in the NAT on the left control navigation bar and follow other examples in there that are working. I almost always forget this and scratch my heads for about an hour before I realize I have forgotten it (and even blogged about it!) If Phase 1 and 2 go OK but there still is no connection, then check the NAT table. Since there are a lot of people like me, they have forgotten the NAT exception too on their end. Be sure to ask them too.
  • Be sure that PFS (Perfect Forwarding Secrecy) mode are matched on both ends. This is at the bottom of the Tunnel Policy (Crypto Map) - Basic panel.
  • Also be sure that the traffic rules and netmasks match between two servers identically. If other side is going for 255.255.255.255 on individual IP address than you have do that on your end as well.You cannot use a wider mask on one end even the range includes the address you are accessing. The traffic access lists from both ends must match exactly.
  • Now would also be a good time to download a TFTP client (may of them are out there), and backup your config on your local disk. Keep that config in Goodle Drive or somewhere with a descriptive file name (like ASA-5505-120605-AddedBostonOffice.txt) out in the cloud so that you won't lose it.

Thursday, September 13, 2007

CISCO ASA 5510, 5505 VPN Removing peer from peer table failed, no match! Error

Symptom

When you try to connect CISCO VPN client you get this error in the log and it will not connect.

4 Sep 13 2007 11:05:12 713903 Group = DefaultRAGroup, IP = xxx.xxx.xxx.xxx, Error: Unable to remove PeerTblEntry

3 Sep 13 2007 11:05:12 713902 Group = DefaultRAGroup, IP = xxx.xxx.xxx.xxx, Removing peer from peer table failed, no match!

Possible Cause

This error message is misleading and leads you to beleive there is something really wrong about your configuration.

But it could simply mean that there is a mismatch, miss-spelling or missing entry the Group ID that is configured on the CISCO VPN client and the Group ID on the Tunnel Group setting.

I guess that the ASA is picking up the default group policy as it is not finding the correct one.

Solution

Check under the tunnel group in your running configuration.

tunnel-group type ipsec-ra

Go to the CISCO VPN client, go to the Authentication tab and the Name field must match what you used in

Monday, September 10, 2007

Windows .NET Service Program Does Not Fire Timer

Scenario:

  • You started to write a Windows Service using C# and Visual Studio 2005.
  • You dragged a Timer object into the service component's design surface.
  • You wrote a Timer handler object.
  • Timer never fires.

Solutions:

The fact that VS 2005 allows you to drag the timer (or other objects) is very misleanding. It actually never works because timer event will never be fired. In theory they (Visual Studio) should not allow you to do that. (I swear it worked in 2003 but that's the past.)

There are numerous postings, messages and such all over the places on this. It took me half a day to figure this out.

But the reason why the timer event does not fire is because under the Service execution model, it does have a "message pump" executing like in windows desktop apps.

The only way that I know it works is to use System.Threading object, launch a thread and then you block the thread by N milliseconds using the sleep function within the thread to achive the same result.

If you want an example of this, I can elaborate here. Just write a comment.

Windows .NET Programmatically Configure Network Interface with C#

Problem: I want to write a C# program that will configure IP address(es).

Why this is useful?

You may have one server and a backup server (say a web server) and you would want to write a program to automatically move the second IP address of an interface from the master to the backup server.

Solutions:

This article on Code Project gives seems to be right on http://www.codeproject.com/cs/system/cstcpipwmi.asp

Also helpful is to look at MSDN on the Network Adapter Configuration win32 class page.

http://msdn2.microsoft.com/en-us/library/aa394217.aspx

You would access each of the item in this Win32 class by named array index into the
ManagementObjectCollection object using the member name exactly spelled out.

e.g., string description = objeMO["Description"];

Tuesday, August 28, 2007

MacOS: Automatically Mounting Network Drive on Mac With or Without Automator

Ever since I put my LaCie ED Mini Network Attached Storage (NAS) on the network, I had to manually mount the ED Mini every time I rebooted the computer. This was very inconvenient, as you go to the Finder and everytime you re-connect you need to type in the password. I have been searching the way to do this easier and finally figured this one out.

One word of caution. Anything you do, password string will be included.

The easiest way to do this, but not secure as password is out in clear text is to do this,

Go to Connect To Server on Finder and punch in your NAS's IP address. In my example I am using 192.168.1.10, it will obviously be different at your home. Suppose your user name is many and password of zyzzx and my Apple file share is called ED_mini then the syntax is,

afp://manny:zyzzx@192.168.1.10/ED_mini

May be a bit more secure way to do this is to use Automator and then create an Application and include the following Apple Script.

on run {input, parameters}

mount volume "afp://manny:zyzzx@192.168.1.10/ED_mini"

return input
end run
  1. Open the automator
  2. Select the Automator from the Library menu
  3. Drag Run Apple Script to the workspace on the right.
  4. You will see the spot to(* Your script goes here *) repalce that with the connection script of mount volume "afp://manny:zyzzx@192.168.1.10/ED_mini"
  5. Test the script and save as an Application. Close automator.

Thursday, August 09, 2007

Fix: LaCie ED Mini Web Interface Stops Working

Symptom:

After running the LaCie ED Mini and try to access the Web Admin interface, you might get the following message.
/www/cgi-bin/public/sharelist: line 219: cannot create temp file for here document: No space left on device

© Copyright LaCie 2004

/www/cgi-bin/public/sharelist: line 246: cannot create temp file for here document: No space left on device
This is due to the log file getting too big.

First clear the log.

http://192.168.0.xxx/cgi-bin/admin/log?do=clearlog

You do need to remember what was your admin password is. This is by default admin.

Above will give the same error, but the log will clear and second time you access LaCie, it will work.

Don't call LaCie for support. They will give you a firmware, in that case, you will lose all the files on your device.

The fact that this is happening to you mean that the system may be logging a lot of errors. Start checking the log and eliminate root cause.

Thursday, May 31, 2007

SQL Server 2005 Cannot Uninstall due to IIsMimeMap

Today I was trying to remove and reinstall an SQL Server 2005 installation from one of my servers. This resulted in the following error

The setup failed to read IIsMimeMap table. The error code is -2147024893

I did some search on the net and this MSDN Post had the answer.

The main cause of this is that there is some interaction with the IIS with the Reporting Service in the SQL server 2005 installation.

It is actually easy to work around this issue.

  • Go to the service control panel.
  • Find IIS Administrator
  • Disable the service and stop it.
  • Uninstall the SQL 2005 (by now the only remenant is the uninstalled Reporting service).

That will work.

Friday, May 25, 2007

How to Clear Voicemail Message Waiting Icon on Cingular/ATT

It is really annoying when there actually is no message on the voice mail but the message waiting indicator continue to be on.

This usually is not a problem for those who get a lot of messages, but I hardly get a voice mail message (goes to say I am really so good at managing people, or I am really unpopular... who cares! Well, actually I get most of my messaging via email.)

But if this ever happens remember;

Don't call "Cingular and now AT&T!" to have this fixed. I tried Actually they cannot or will not reset this from their end.

But there is an easy 2-minute solution to this. Just leave a message on your cell phone yourself from another phone and listen to it from the cell phone. That will make it go away.

Friday, May 04, 2007

XCOPY incompatible with NTFS Mount Points

Well it is bizarre and the final answer may be elsewhere, and it may even be specific to our iSCSI SAN configuration etc.

But you might run into the same situation as I have.

We wanted to copy the entire directory and files underneath it from one place in a file system (say a network share) to under a mount point directory (say C:\lotsofiles) in hosted by an iSCSI SAN, and to do so, I used XCOPY commands.

What happens next, when you do this is that XCOPY ignores the mount point and happily copy files to the drive. We saw the C: drive's space directly. As soon as XCOPY starts to run, it will cause some error and ISCSI volumes are no longer bound!

This issue does not occur, for example if you drag and drop files using the Explorer, use COPY command or do a deep copy using cp.exe in the UnxUtils package. So I know it is very specific to XCOPY