Server 2008 hiberfil.sys exists…

•June 25, 2010 • Leave a Comment

Tidbit of information, I just ran out of space on a 2008 web server’s c:\ drive and found the hiberfil.sys file was 4gb… also had some log files to clear but found this information about the hiberfil.sys in a M$ forum somewhere. I executed the command on my server and it went away …


By default, in Windows Server 2008, the Hibernation feature is disabled (power options), yet the hiberfil.sys file is created. The hyberfil.sys file has the size of the servers’ physical memory, which can be many gigabytes. This is pointless because hibernation is not supposed to be used on production servers at all. A complete waste of resources. It may even be included in backups … (haven’t verified this)

At best, the hibernation feature may be used in Windows Server 2008 test/demo environments. Even there it shouldn’t be enabled by default and there shouldn’t be a hyberfil.sys file.

powercfg.exe -h off

This command worked and removed the hiberfil.sys.

I agree, it’s really not a good idea to have that by default. The excuse that it exists in case of power-failure and switch to UPS makes no sense. You don’t need hiberfil.sys to protect you from power-failure. We’ve never had a problem with a properly configured UPS setup on a server when there is a powerfailure. If you turn off hibernation, the file should go away, period! If it’s turned off by default then the file shouldnt’ exist by default. Typical MS logic. Either way, not a big deal to get around.

Advertisements

ASP.NET Image Rollover Using VB

•June 23, 2010 • Leave a Comment

For a simple image rollover using your vb codebehind page and a couple of png files or whatever file type you wish to use. I’m not sure where I found this bit of script but it came in handy a few weeks ago!


<asp:ImageButton runat="server" ID="tbimage" ImageUrl="img/LeftMenuButton.png" Style="float: left;
outline: 0; width: 21px" />

In your VB Codebehind page:


    Private Sub Page_Load(ByVal sender As System.Object, _
        ByVal e As System.EventArgs) Handles MyBase.Load

        tbimage.Attributes.Add("onMouseOver", _
            "this.src='img/LeftMenuButton2.png';")
        tbimage.Attributes.Add("onMouseOut", _
            "this.src='img/LeftMenuButton.png';")
      
    End Sub

Sending Email with System.Net.Mail

•June 23, 2010 • Leave a Comment

I haven’t tested this one but I got it off of ScottGu’s blog which has some great stuff on it…

Read Scott’s Original Post

.NET 2.0 includes much richer Email API support within the System.Net.Mail code namespace. I’ve seen a few questions from folks wondering about how to get started with it. Here is a simple snippet of how to send an email message from “sender@foo.bar.com” to multiple email recipients (note that the To a CC properties are collections and so can handle multiple address targets):


MailMessage message = new MailMessage();
message.From = new MailAddress("sender@foo.bar.com");

message.To.Add(new MailAddress("recipient1@foo.bar.com"));
message.To.Add(new MailAddress("recipient2@foo.bar.com"));
message.To.Add(new MailAddress("recipient3@foo.bar.com"));

message.CC.Add(new MailAddress("carboncopy@foo.bar.com"));
message.Subject = "This is my subject";
message.Body = "This is the content";

SmtpClient client = new SmtpClient();
client.Send(message);

 

System.Net.Mail reads SMTP configuration data out of the standard .NET configuration system (so for ASP.NET applications you’d configure this in your application’s web.config file). Here is an example of how to configure it:


  <system.net>
    <mailSettings>
      <smtp from="test@foo.com">
        <network host="smtpserver1" port="25" userName="username" password="secret" defaultCredentials="true" />
      </smtp>
    </mailSettings>
  </system.net>

DNS Record Types

•June 23, 2010 • Leave a Comment

Just some DNS information that is good to understand if you are manageing dns records for a website or company…

An ‘A’ or ‘Address’ record ties a domain name to an IP address. If there is a server on the Internet that is configured to handle traffic for this domain, you can enter the name of the domain ocalafl.org and the IP address of the server (for example ‘64.85.73.21’) and your domain will point to that IP address.

Examples:
ocalafl.org A 64.85.73.21
http://www.worldcrossings.com A 64.85.73.21

A ‘CNAME’ or ‘Common Name’ creates an alias from a domain name to another. For example, you can create a CNAME from ‘subdomain.ocalafl.org’ to ‘www.internet.com’, and every reference to ‘subdomain.worldcrossings.com’ will go to ‘www.internet.com’, regardless of how http://www.internet.com changes their IP addresses.
Please note that if you define a CNAME for one of your subdomains, there should be no A or MX record defined for that subdomain.

Examples:
worldcrossings.com CNAME http://www.internet.com
subdomain.worldcrossings.com CNAME http://www.internet.com
subdomain.worldcrossings.com CNAME http://www.worldcrossings.com

An ‘MX’ or ‘Mail Exchange’ record is used to specify what server on the Internet is running e-mail software that is configured to handle e-mail for your domain. Additionally, if you define several MX records, the Priority lets you specify the order in which they should be tried. Mail servers with the lowest pritority will be tried first.

Examples:
worldcrossings.com MX 0 mail1.worldcrossings.com
worldcrossings.com MX 5 mail2.worldcrossings.com
subdomain.worldcrossings.com MX 0 mail1.worldcrossings.com
subdomain.worldcrossings.com MX 5 mail2.worldcrossings.com

An ‘NS’ or ‘Name Server’ record allows you to delegate one of your subdomains to other name servers. These other name servers are responsible for providing A, MX, etc. records for the delegated subdomain. Note that to change the NS records for your base domain name (ocalafl.org), you must do it through the domain’s registrar. To change the name servers of domains of which we are the registrar, use the “update name servers” link on our main account management page.

Examples:
subdomain.worldcrossings.com NS ns1.worldcrossings.com
subdomain.worldcrossings.com NS ns2.worldcrossings.com

A ‘TXT’ or ‘Text’ record allows you to add a comment to a domain or subdomain record that will be available through DNS. A common use for TXT records is to specify a Sender Permitted From (SPF) record for a domain. You can find more information about SPF at: http://www.openspf.org or use the SPF wizard at: http://old.openspf.org/wizard.html

Examples:
worldcrossings.com TXT For Questions, contact: me@mydomain.com
worldcrossings.com TXT ‘v=spf1 a:mail.ocalafl.org’

ASP.NET Simple Email Form

•June 22, 2010 • 1 Comment

I was needing to create an email form and ended up finding some other issues with sending the values from checkboxlists. This was taken from several different sites, it should work with no troubles. I also added a try/catch statement to catch errors. If you have any questions, don’t hesitate to contact me. thx.

The form html code in the contactform.aspx


<center>
        <fieldset style="padding: 10px;">
            <legend style="margin-top: -10px;">Please enter your information: </legend>
            <table border="0">
                <tr>
                    <td>
                        <b>Your Name:</b>
                    </td>
                    <td>
                        <br />
                        <asp:textbox ID="txtName" runat="server" EmptyMessage="Please input your name."
                            Skin="Default" Width="200px" CausesValidation="True">
                        </asp:textbox>
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" ErrorMessage="*"
                            ControlToValidate="txtName"></asp:RequiredFieldValidator>
                    </td>
                </tr>
                <tr>
                    <td>
                        <b>Your Email:</b>
                    </td>
                    <td>
                        <asp:textbox ID="txtEmail" runat="server" EmptyMessage="Please input your email address."
                            Width="200px" CausesValidation="True">
                        </asp:textbox>
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="*"
                            ControlToValidate="txtEmail"></asp:RequiredFieldValidator>
                    </td>
                </tr>
                <tr>
                    <td colspan="2">
                        Your email address will ONLY be used to configure your account and respond appropriately.
                        <br />
                        It WILL NOT be sold, or used to send you spam.
                        <hr />
                    </td>
                </tr>
                <tr>
                    <td colspan="2" align="left">
                        <fieldset>
                            <legend>Please select the departments you commonly work with: </legend>
                            <asp:CheckBoxList ID="txtCheckBox" runat="server" RepeatColumns="4">
                                <asp:ListItem>One</asp:ListItem>
                                <asp:ListItem Text="Two" />
                                <asp:ListItem Text="Three" />
                                <asp:ListItem Text="Four" />
                                <asp:ListItem Text="Five" />
                                <asp:ListItem Text="Six" />
                                <asp:ListItem>Seven</asp:ListItem>
                                <asp:ListItem>Eight</asp:ListItem>
                                <asp:ListItem>Nine</asp:ListItem>
                                <asp:ListItem>Ten</asp:ListItem>
                            </asp:CheckBoxList>
                        </fieldset>
                    </td>
                </tr>
                <tr>
                    <td colspan="2">
                        <b>Comments:</b>
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ErrorMessage="*"
                            ControlToValidate="txtComments"></asp:RequiredFieldValidator><br />
                        <asp:textbox ID="txtComments" TextMode="MultiLine" runat="server" Width="400px"
                            Height="200px" EmptyMessage="Please tell us how we can assist you!" CausesValidation="True">
                        </asp:textbox>
                    </td>
                </tr>
                <tr>
                    <td colspan="2" align="center">
                        <asp:Label ID="lblMessage" runat="server" Text="" ForeColor="Green"></asp:Label>
                        <asp:Button runat="server" ID="SendEmail" Text="Send Feedback" />
                    </td>
                </tr>
            </table>
        </fieldset>
    </center>


My entire VB Codebehind for contactform.aspx.vb




Partial Class accessrequest
    Inherits System.Web.UI.Page

    Protected Sub SendEmail_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles SendEmail.Click
        '!!! UPDATE THIS VALUE TO YOUR EMAIL ADDRESS
        Const ToAddress As String = "tthomas@ocalafl.org"

        '(1) Create the MailMessage instance
        Dim mm As New Net.Mail.MailMessage(txtEmail.Text, ToAddress)


        Dim strchklist As String = ""
        Dim li As ListItem

        For Each li In txtCheckBox.Items()
            If li.Selected Then
                strchklist += li.Text + " <br /> "
            End If
        Next

        'This is extra code that can be used or deleted for the checkboxlist
        'If strchklist = "" Then
        '    Response.Write("No item Selected")
        'Else
        '    Response.Write(("You selected : " + strchklist))
        'End If

        '(2) Assign the MailMessage's properties
        mm.Subject = "Website Form: File Management Site New User Request Submitted."
        mm.Body = "<h2>Your Heading for Email</h2> Customer's Name: " & txtName.Text & "<br />Customer's Email: " & txtEmail.Text & "<br />Customer's Comments:" & txtComments.Text & "<br /> Customer's Selections: " & txtCheckBox.SelectedItem.Selected

        mm.IsBodyHtml = True

        Try
            '(3) Create the SmtpClient object
            Dim smtp As New Net.Mail.SmtpClient

            '(4) Send the MailMessage (will use the Web.config settings)
            smtp.Send(mm)

            ' show message on screen that email has been sent
            lblMessage.ForeColor = System.Drawing.Color.Green
            lblMessage.Text = "<strong>Email Sent SucessFully</strong><br><hr>"

            ' display error message
        Catch ex As Exception
            lblMessage.ForeColor = System.Drawing.Color.Red
            lblMessage.Text = "There was a problem sending the email, the error is: <br />" & ex.Message & "<br><hr>"
        End Try

    End Sub

End Class



In your webconfig add this under ‘configuration’


  <system.net>
    <mailSettings>
      <smtp>
        <network
             host="mail.yourserver.com"
             port="25"
             userName="username "
             password="password"
             />
      </smtp>
    </mailSettings>
  </system.net>

The remote computer that was reached is not the one you specified…

•April 1, 2010 • Leave a Comment

The Error: The connection cannot be completed because the remote computer that was reached is not the one you specified. This could be caused by an outdated entry in the DNS cache. Try using the IP address of the computer instead of the name.

Make sure the time on the target server is accurate. It has to be within 5 minutes of the DC usually or servers and workstations start to act funny, though it should be exact. I corrected the time on my newly reformatted target server (2008 not R2) and immediately connected afterwards from my Win7 PC.

40 years old …

•March 8, 2010 • Leave a Comment

Yep, time to get in shape …  🙂