Blocking IP addresses through IIS

by Jeremy Brown 11. May 2012 21:07

Follow the instructions in the link below for blocking specific IP addresses through IIS

http://blog.lowtek.com/2006/09/how-to-block-ip-address-on-windows.html

Tags:

Windows 2003 Server | IIS

ASP.NET postbacks loses URL Rewriting

by Jeremy Brown 1. May 2012 20:41

You may have noticed in ASP.NET when you do a postback on the page it loses the URL rewriting so something like www.mysite.com/news-article-1 becomes www.mysites.com/news.aspx?id=1

I found a solution to this here http://stackoverflow.com/questions/5191612/asp-net-postbacks-creates-problem-in-url-rewriting

In the Master Page page load event place the following code:

form1.Action = Request.RawUrl;

form1 being the id of your form tag.

Tags:

ASP.Net | Url Rewriting

Useful MIME types

by Jeremy Brown 3. February 2012 01:43

Useful MIME types for Microsoft Office documents:

You upload a file to your CMS via your rich text box but you get a 404 error.

The solution to this is Internet Information Services (IIS)


Out of the box, IIS6 only accepts requests for known MIME types. Since Office 2007 was released after Windows Server 2003 and IIS6, IIS6 knows nothing about the new MIME types. So you need to manually add them:

    Open Computer Management. (Right-click My Computer… Manage…)
    Right-click Internet Information Services (IIS) Management… Properties…
    Click MIME Types…
    Click New… and add the following:

.docx application/vnd.openxmlformats-officedocument.wordprocessingml.document
.xlsx application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
.pptx application/vnd.openxmlformats-officedocument.presentationml.presentation

Tags:

Hosting

SQL Server Code to Find Total Size of Database

by Jeremy Brown 2. February 2012 22:10

Total database size script

SELECT

[SpaceUsed(KB)] = SUM(alloc.used_pages)*8

FROM sys.objects obj

JOIN sys.indexes idx on obj.object_id = idx.object_id

JOIN sys.partitions prt on obj.object_id = prt.object_id

JOIN sys.allocation_units alloc on alloc.container_id = prt.partition_id

WHERE

obj.type = 'U' AND idx.index_id IN (0, 1)

Tags:

Issue with PrettyPhoto and partial-page postbacks

by Jeremy Brown 24. November 2011 01:27

I had a problem with PrettyPhoto not working within an Update Panel.  I found this solution which seems to do the trick:

http://forums.asp.net/p/1468161/3723242.aspx

<script type="text/javascript">
  function pageLoad() {
    $("a[rel^='prettyPhoto']").prettyPhoto();
  }
</script>

 

Tags:

Javascript | prettyPhoto

301 redirect without touching IIS (VB.NET)

by Jeremy Brown 10. October 2011 18:23

Just a method of doing a 301 redirect from non-www to www I came across rather than doing it through IIS
http://www.barrywise.com/2008/10/seo-canonical-urls-and-301-redirects-in-windows-iis-6-iis-7/


        Try
            Dim requestedDomain As String = HttpContext.Current.Request.Url.ToString().ToLower()

            If InStr(requestedDomain, "http://thewebbureau.com") Then

                requestedDomain = requestedDomain.Replace("http://thewebbureau.com", "http://www.thewebbureau.com")

                Response.Clear()
                Response.Status = "301 Moved Permanently"
                Response.AddHeader("Location", requestedDomain)
                Response.End()

            End If

        Catch ex As Exception
            Response.Write("Error in Global.asax :" & ex.Message)
        End Try

Tags:

SQL Server Code to Find Size of Tables Within a Database and ORDER BY table size

by Jeremy Brown 23. September 2011 00:43

Found this script which allows you to order by table size http://www.sqlservercurry.com/2011/02/sql-server-count-rows-in-tables-and-its.html

 

-- Count All Rows and Size of Table by SQLServerCurry.com

SELECT

TableName = obj.name,

TotalRows = prt.rows,

[SpaceUsed(KB)] = SUM(alloc.used_pages)*8

FROM sys.objects obj

JOIN sys.indexes idx on obj.object_id = idx.object_id

JOIN sys.partitions prt on obj.object_id = prt.object_id

JOIN sys.allocation_units alloc on alloc.container_id = prt.partition_id

WHERE

obj.type = 'U' AND idx.index_id IN (0, 1)

GROUP BY obj.name, prt.rows

ORDER BY [SpaceUsed(KB)] desc 

Tags:

Name 'Session' is not declared - VB.NET

by Jeremy Brown 28. January 2011 02:06

In a class you need to declare a session slightly differently:

HttpContext.Current.Session("SessionName")

Tags:

VB.Net

BlogEngine Error - 'Could not save post: The specified string is not in the form required for an e-mail address.'

by Jeremy Brown 26. January 2011 18:45

This error message will occur when there is an invalid email address in the App_Data\Newsletter.xml file.  This XML file contains email addresses of people who have signed up for the Newsletter (via the Newsletter widget).  When you save a post, all the people in that file are sent an email.  If an invalid email address exists, it will throw this error message.

If you remove any invalid email addresses from this XML file you may need to restart the blog for your changes to be detected.  To restart the blog, simply modify the web.config file (e.g. add a space).

Tags:

BlogEngine

Get current users and processes in SQL Server

by Jeremy Brown 26. January 2011 02:17

SQL Server has a system stored procedure you can run called sp_who that will provide you with information on the current SQL Server userse and processes.  This can be filtered to return processes that are not idle.

Tags:

SQL Server

 

Posts By Date

Log in