BeetleDev.com
info
contact
Saturday, September 04, 2010
Beetle Blog
1 2 3
By: douglas - ASP.net - 8/24/2010 1:10:44 AM

 Issue:

Your asp.net application uses the membership and roles provider and users have checked the "remember me" option when logging in that uses a persistent cookie to keep a user logged in.  If the app pool for an asp.net application is recycled the user may become logged out even though the cookie has not expired and still exists.

This issue most often appears in a web farm but can appear in a single server environment.

Cause:

The cookie becomes invalid because the machine key for the application has changed after the app pool recycles.  The machine key is used to read the persistent cookie.  Since it has changed your application can no longer read the cookie and users appear to be logged out.

Solution:

Add a static segment to the web.config.  This will make your application use the same machine key even after an app pool recycle.

Additional Information:

About Machine Key:

http://msdn.microsoft.com/en-us/library/ms998288.aspx#paght000007_machinekeyexplained

Tool for generating a Machine Key for the web.config:

http://aspnetresources.com/tools/machineKey

 


By: douglas - Sql Server - 5/1/2010 7:33:52 PM

 If you try to run a very large script in SQL Management Studio (2005, 2008) it may not run.  Instead it may give a "System.OutOfMemoryException" error.

In order to run the script you can use the sqlcmd in the command line instead.

sqlcmd -S YOURSQLSERVER\INSTANCENAME -i "C:\Your Script.sql”


By: douglas - Classic ASP - 2/13/2010 1:43:41 PM

By default Classic ASP is turned off on IIS7.

To enable:

  • Use the Control Panel to turn on Windows Features.  Under Internet Information Services > World Wide Web Services > Application Development Features check ASP
  • Then, for better debugging features under ASP in your IIS web site set "Send Errors To Browser" to True under "Debugging Properties" and Apply the settings.

 


By: douglas - ASP.net - 4/10/2009 9:41:59 PM

After installing ASP.net MVC v1 it is supposed to install the ASP.net MVC project template into VWD2008.

If it does not, make sure you have VWD2008 sp1 and then go to "Tools" > "Import and Export Settings..." and reset the VWD settings.

Now you should be able to create ASP.net MVC projects in VWD2008.


By: douglas - ASP.net - 8/7/2008 1:15:13 AM

When you use a LinqDataSource as the datasource for a GridView you may run into an issue if you try to display data from a child object/table in the LinqDataSource.

For example if you have an object Order and child object Customer trying to call Customer.FirstName will be blank.  This is a bug in .net 3.5.

If you set EnableDelete, EnableInsert or EnableUpdate on the LinqDataSource the Eval statement will work.

Other workarounds and details can be found here:

http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2995461&SiteID=1

http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2469812&SiteID=1


By: douglas - ASP.net - 5/28/2008 3:16:14 PM

This seems to be an error in the ASP.net runtime.

It can happen with MasterPages or UserControls.  Often it will happen after you update a file and place it on the server.   ASP.net is not able to always compile properly.

There is a hotfix from Microsoft for this.

http://support.microsoft.com/kb/915782

There is a workaround for this issue:

<configuration>

   
<system.web>
       
<compilation debug="false" batch="false"></compilation>
   
</system.web>

</configuration>


By: douglas - C# - 5/22/2008 3:56:27 AM

This code uploads an image to the server file system.  If the image is wider than a certain width it resizes the image.  The image is saved as a jpg.

 

        // Upload image
        // Make sure to create directory if needed.
        string savePath = Server.MapPath("~/UploadFolder/");

        // Create Directory if it doesn't exist
        if (!System.IO.Directory.Exists(savePath))
        {
            System.IO.Directory.CreateDirectory(savePath);
        }


        // Declare some image variables
        System.Drawing.Image imgOriginal;  // Will hold the original image
        System.Drawing.Image imgNew;  // Will hold the new image
        double targetWidth = 100; // Default target width for new image
        double targetHeight = 100; // Default target height for new image

        // Get new width from config
        try
        {
            targetWidth = Convert.ToDouble(ConfigurationManager.AppSettings["MaxImageWidth"]);
        }
        catch
        {
            targetWidth = 100;
        }

        //Create a new Image using the uploaded picture as a Stream
        imgOriginal = Bitmap.FromStream(ImageUpload.PostedFile.InputStream);

        // Work out a proportionate height from width
        if ((double)imgOriginal.Width < targetWidth)
        {
            targetWidth = (double)imgOriginal.Width;
            targetHeight = (double)imgOriginal.Height;
        }
        else
        {
            targetHeight = (double)imgOriginal.Height / ((double)imgOriginal.Width / targetWidth);
        }

        // Now create the new image
        imgNew = new Bitmap(imgOriginal, (int)targetWidth, (int)targetHeight);

        // Save it to the file system as a jpg.
        imgNew.Save(savePath + "\\" + pAdID.ToString() + ".jpg", System.Drawing.Imaging.ImageFormat.Jpeg);
 


By: douglas - C# - 4/28/2008 6:13:14 AM

The following will validate stringVariable to see if it matches an email pattern.

System.Text.RegularExpressions.Regex.IsMatch(stringVariable, "\\w+([-+.']\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*");

There are double \ due to the language being C#.

 


If you are using the command prompt on Windows many directories and file names have spaces in their names.  This does not work well with the command prompt.  One solution is to put double quotes around paths with spaces:

"C:\Program Files\My File.exe"

 


When you have an SqlDataSource that has a SelectCommand and Select parameters.  If the select parameters are optional or null the datasource will not return any records.

This may occur when using a stored procedure.  Testing the datasource in visual studio returns records and testing the stored procedure will also return records.  However the datasource and datagrid it binds to does not return any records.

The issue may be caused by a property in the SqlDataSource: CancelSelectOnNullParameter.  This property is defaulted to true and will prevent the select command from running if select parameters are null.

Set CancelSelectOnNullParameter="false"



By: douglas - ASP.net - 12/29/2007 12:23:55 AM

Here is how to start the standalone server that comes with VS.net 2005 and higher from the command line:

Start /B C:\WINDOWS\Microsoft.NET

\Framework\v2.0.50727\WebDev.WebServer.exe /port:1234 /path:"C:\YourWebSitePath"
 
If you place this line in a bat file you can start your web server by running the bat file.
 
WebDev.WebServer.exe is the web server.
 
 
 

By: douglas - Misc - 12/14/2007 6:37:16 PM

In VS.net 2005:

  1. Create a dataset file
  2. Drop a database table in the dataset
  3. Generate stored procedures
  4. Generate database insert, update, delete methods
  5. Close dataset file
  6. Open dataset file
  7. Configure dataset
  8. Go through wizard
  9. Now the generator does not generate the insert, update and delete methods
  10. This also happens if you create a new data set based on existing stored procedures

Possible workaround:


Creating a new TableAdapter in the DataSet Designer by right-clicking on the designer surface and choosing Add->TableAdapter. Then go through the wizard choosing Use Existing Stored Procedures. The checkbox will still be disabled but it will be checked and the DBDirect methods will be created. You will also be able to turn on/off the GenerateDBDirectMethods property in the properties window by following this workaround.


By: douglas - Misc - 11/12/2007 1:55:10 AM

Recently I've been working on animalpedia.com.  Animalpedia.com is a web site all about animals and I plan to make it a cross between a blog and wiki type site.  Hopefully it can be developed enough so that people will be able to use it as a resource for animal information and pictures.

Check it out at www.animalpedia.com.


By: douglas - ASP.net - 4/8/2007 3:29:13 PM
When using the PopupControl extender, if you run into an issue where the popup control does not pop up in the correct position when the page is scrolled you should make sure you have these HTML elements on your page:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >

By: douglas - Misc - 10/18/2006 1:45:37 AM
Recently I tried out Ubuntu (www.ubuntu.com).   I found it to be very easy to install and use.


By: douglas - ASP.net - 10/18/2006 1:23:27 AM
By default the ASP.net upload control is limited to around a 2 MB upload.  Trying to upload larger files result in an error.

To set the upload capacity of the upload control place these tags in the web.config:

<httpRuntime maxRequestLength="655350" useFullyQualifiedRedirectUrl="true" executionTimeout="600" />

Or:

<httpRuntime

executionTimeout="90"

maxRequestLength="4096"

useFullyQualifiedRedirectUrl="false"

minFreeThreads="8"

minLocalRequestFreeThreads="4"

appRequestQueueLimit="100"

/>


By: douglas - Misc - 10/28/2005 2:32:37 AM

Subversion is a source control system.

Subversion main link:
http://subversion.tigris.org/

 


By: douglas - Misc - 10/28/2005 2:28:54 AM

CruiseControl.net is a server that is used to run builds on software projects.

It works together with source control, NAnt, NUnit and other tools to build projects.

Here are some links to CruiseControl.net sites:

CCNet Main Site:
http://confluence.public.thoughtworks.org/display/CCNET/Welcome+to+CruiseControl.NET

How to set up a CCNet project:
http://joefield.mysite4now.com/blog/articles/146.aspx

 


By: douglas - ASP.net - 9/24/2005 2:20:48 PM

These are good articles that show how to implement event bubbling with ASP.net.  Event bubbling is where an event in a user control can be handled by the parent page/control or another control.

http://authors.aspalliance.com/tempest/bubble.aspx

http://odetocode.com/Articles/94.aspx


By: douglas - Misc - 9/24/2005 2:18:01 PM

A friend of mine emailed me this link a couple of years ago.  It's an index on the popularity of programming languages.

http://www.tiobe.com/tpci.htm


1 2 3

Beetle Blog v0.2.2


Copyright © 1997 - 2010 BeetleDev.com. All rights reserved.