Category Archives: IIS 6

[RESOLVED] Hosting 4.0 web application

i tried to implement url routing feature in 4.0 and tried to host in my machine in IIS. but i get an error.

HTTP Error 404.0 - Not Found

The resource you are looking for has been removed, had its name changed, or is temporarily unavailable.

The code i used

protected void Application_Start(object sender, EventArgs e)

void CustomRouteTable(RouteCollection routes)

            routes.MapPageRoute("Telugu", "Movie/Telugu", "~/Telugu/Telugu.aspx");


and one in default.aspx page and on click of the button i wrote:

protected void btnTelugu_Click(object sender, ImageClickEventArgs e)

is it due to the page is kept inside the Folder in my application???

How to handle this scenario???

Thanks...Please guide me...

Are you certain that IIS is set up to host .net 4.0?

Check your IIS setttings. 

How to know whether the IIS is set up to host .net 4.0???

what are the steps?? Could you guide me???

I had made the application pool ->Asp.net4.0

should i select application pool-> Asp.net4.0 classic  ???

If you are using IIS 7 then yes, I always switch to Classic, while developing in VWD2008.

Classic has worked for me. 


Let me check into my server settings I will try to post later.



Under web sites in IIS 6, look at properties then on the folder tab, be certain you first have .net 4.0 available.

I don't know of setting in IIS6 App Pool for level.


i could solve the issue with applying the below code in my web.config file...

    <modules runAllManagedModulesForAllRequests="true">

      <add name="UrlRoutingModule"
                   System.Web.Routing, Version=,
                   PublicKeyToken=31BF3856AD364E35" />
      <!-- ... -->


      <add name="UrlRoutingHandler"
            verb="*" path="UrlRouting.axd"
                  System.Web, Version=, Culture=neutral,
                  PublicKeyToken=b03f5f7f11d50a3a" />
      <!-- ... -->


but i have two more issue....

1) i am not able to make url setting for Default.aspx page which is start page...i am also getting Default.aspx ( with extension)

2) how to navigate from HTML side??

Not required if you are running .net 3.5 it is backward compatible and will support 2.0


Can you help me to find out the ans for above 2 question which i posted ? 

Check out som eof the VIDEOS at this link

There are white papers and videos, search for the videos for a faster start.




  Thanks..I could get the issue resolved for ul and li with the help of ResolveUrl approach.

[RESOLVED] Url Rewring in not working

I have used urlrewring in 4.0 usng System.Web.Routing.RouteCollection to use access of pages without extension.

Its working on dot net server. But itsa not working on iis.Please provide me solution.

if you are using iis 6.0 then go to iis right click your site and select properties

now go to virtual directory tab and click the button named Configuration

now select the .aspx extension and click edit . there you will find a checkbox named check that file exists

Uncheck that check box and save the changes and then reset the iis . may be your problem is gone.

[RESOLVED] BinaryWrite image from Database is corrupt on download

We have been downloading Office 2003 documents stored in our database as images successfully using our ASP.NET 2.0 web portals. We recently started storing Office 2007 documents and though they upload without issue, the download and render does not work. The file opens with the error - "The file is corrupt and cannot be opened". It is only with Office 2007 files we see this. The web server supports the Office 2007 MIME types. We also apply the correct content-type when uploading a file to the database. Sample BinaryWrite code below. Is there something I am overlooking unique to Office 2007 files?



Dim MyData() As  Byte
MyData = dreader("document")
Response.ContentType = "application/vnd.openxmlformats-officedocument.wordprocessingml.document"
Response.AddHeader("Content-Length", MyData.Length.ToString())
Response.AddHeader("Content-Disposition", "attachment; filename=" & dreader("file_name").ToString)


Try adding a Response.End() to make sure the server does not send and additional bytes after the file has been fully sent.

Please show the code you use to store the files?

Dim fs As FileStream
Dim st As Stream
Dim cmdInsertDocument As New System.Data.SqlClient.SqlCommand
' Read file into file stream
fs = File.Open(ViewState("file_path").ToString, FileMode.Open, FileAccess.Read)
st = fs
Dim MyData(st.Length) As Byte
st.Read(MyData, 0, st.Length)
fs = Nothing

With cmdInsertDocument
' Set the properties of the SQL command
.CommandText = "usp_InsertTFSDocument"
.CommandType = CommandType.StoredProcedure
.Connection = conTVMR
.Parameters.Add(New System.Data.SqlClient.SqlParameter("@case_id", System.Data.SqlDbType.NVarChar, 50))
.Parameters.Add(New System.Data.SqlClient.SqlParameter("@section_id", System.Data.SqlDbType.Int, 4))
.Parameters.Add(New System.Data.SqlClient.SqlParameter("@desc", System.Data.SqlDbType.NVarChar, 50))
.Parameters.Add(New System.Data.SqlClient.SqlParameter("@file_name", System.Data.SqlDbType.NVarChar, 50))
.Parameters.Add(New System.Data.SqlClient.SqlParameter("@date_uploaded", System.Data.SqlDbType.DateTime))
.Parameters.Add(New System.Data.SqlClient.SqlParameter("@uploaded_by", System.Data.SqlDbType.Int, 4))
.Parameters.Add(New System.Data.SqlClient.SqlParameter("@document", System.Data.SqlDbType.Image))
.Parameters("@case_id").Value = Session("user").CaseID
.Parameters("@section_id").Value = CInt(cboSections.SelectedValue)
.Parameters("@desc").Value = Server.HtmlEncode(txtDocumentDesc.Text)
.Parameters("@file_name").Value = ViewState("file_name")
.Parameters("@date_uploaded").Value = Now
.Parameters("@uploaded_by").Value = Session("user").AnalystID
.Parameters("@document").Value = MyData

That's what I thought!

mbanavige was right


make sure the server does not send and additional bytes

With office 2007 files, you need to make sure that you send exactly the right amount of bytes. The problem is, that you store 1 additonal byte....


Dim MyData(st.Length) As Byte

This is the problem, you see it in most examples. But you need to realize that an array is zerobased. So if your image is 1000 bytes, you create an array of 1001 bytes (0 - 1000). The extra byte doesn't make a difference with most files, but it does with Office 2007 files... The solution is very simple:


Dim MyData(st.Length - 1) As Byte

Also, use Response.End() instead of Response.Flush()

That should do it!

Many thx. That solved the problem. I had subtracted 1 from the image length before, but I must have done it on the download instead of the upload. Thx again.

I have reopened this thread because although the proposed solution worked fine on my local machine, it did not work when I moved the .dll files to the model office server. I confirmed that IIS 6.0 has the MIME types for the Office 2007 files, which were added at the +Internet Information Services level. I am seeing corruption errors opening .pptx, .docx and .xlsx files save as before. Have I overlooked something else with IIS?

MIME types I'm using are:


It has nothing to do with IIS. Like I said, the amount of bytes is the problem. I'm not sure what you're trying to tell in your previoius reply, but I already said that when you store the files in the database you're storing 1 byte too much. And also, you need to use Response.End, otherwise some additional bytes will be send also, causing the same problem.

I dashed off my last reply between meetings and so was in a hurry and failed to fully explain what was happening. My apologies.

I made the bytes length change as suggested and it worked when running the app from my dev machine. All the Office 2007 test files uploaded and downloaded without issue. Believing all was corrected I moved the app to our model office server for testing by the user community. Once again the Office 2007 files downloaded, but threw corruption errors upon open. I double-checked the IIS MIME types just to be sure and they are fine. I am at a loss to explain why the .dll files work on my local machine, but do not when placed on the web server.

I did not change the Response.Flush() method to Response.End as I recall that aborts the thread and throws an error. I will, however, make this change and try again.

Once again - my apologies for my earlier unclear post and many thanks for your continued support.


I did not change the Response.Flush() method to Response.End as I recall that aborts the thread and throws an error.

Try Response.Flush on your development machine? It will cause the error. Response.End will solve it....

The Response.Flush() works fine on my local machine. Using Response.Flush() on the server and I get the "file corrupted" error that started this thread. So I changed to use Response.End() and that works locally and on the server. The downside is that Response.End() raises the thread aborted exception. The work-around for this I found - HttpContext.Current.ApplicationInstance.CompleteRequest - does not raise the exception, but the Office 2007 files throw the file corrupt error on open again.

I do believe I have spent enough time on this and will have to live with Response.End() cluttering up my my application log with thread aborted errors. Thank you again for your assistance.

[RESOLVED] url routing default path

Hi, I want to route these 3 paths to default path that is ""


I want to appear these 3 pages in address bar like this: There are only these 3 pages in my project. How can I do this in 3.5 with IIS 6.0.

How can I solve this?

I dont want to response redirect to another page.

I want to display  file. But url on address bar should be .

Try this

void Application_BeginRequest(object sender, EventArgs e)
            switch (HttpContext.Current.Request.Url.AbsolutePath.ToLower())
                case "/page1.aspx":
                 case "/page2.aspx":
                 case "/page3.aspx":



There is an error here:

Server Error in '/' Application.

The resource cannot be found.

Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable.  Please review the following URL and make sure that it is spelled correctly.

Requested URL: /default.aspx


Is there anything to do with this . For Example, some settings in web config?


AbsolutePath contains the entire path; you need to extract the page name. Eg:

        Uri path = HttpContext.Current.Request.Url;
        string pageName = path.Segments[path.Segments.Length - 1];
        switch (pageName.ToLower())


Problem is rewriting the url. It is searching default.aspx file. There is no default.aspx file. There is page1.aspx file.


Why it is searching default.aspx ? I just want to rewrite path..

You need some form of default document, which the web server can display if no page is requested; that's usually default.aspx.  Rewriting keeps the URL the same, but underneath serves a different page. Generally this is used to show nice URLs while underneath the ASPX pages carry on as normal.

What you're after is three different pages, but not to show the URL in the browser - is that it? Because if so, you can't really do that without redirecting. And you can't just have no URL for all three pages; only one can act as the default document.

Why is it that you don't want the page name shown?



It is searching default.aspx file. There is no default.aspx file. There is page1.aspx file.

As Dave Sussman mentioned ,you need to set up a default document:

Dave Sussman

which the web server can display if no page is requested; that's usually default.aspx. 

I would like to suggest you to check the links below for more information about setting Up Default Documents with different version of IIS:

How to add a default document with IIS7 web.config

Setting Up Default Documents (IIS 6.0)

Configure Default Page For Site

By the way ,here is a similar thread which provides some solutions for how to set a default page in

Hope it can help you.

[RESOLVED] Attempted to read or write protected memory. This is often an indication that other memory is corrupt.

I have hosted my website on the remote server. the server having Windows Server 2003 Standard Edition 64 bit OS with IIS 6.0. After hosted the website, it randomely gives me the following error message i.e.

Attempted to read or write protected memory. This is often an indication that other memory is corrupt.

To resume the website, i do stop the sql server and IIS and delete the w3wp.exe from the task bar manager and then restart the sql and IIS in the same sequence and then website works fine.

But this error generate randomely and couldn't resolved yet. How can i get rid of this error it is very annoying situation for me.

Please help.

Thank you.



Attempted to read or write protected memory. This is often an indication that other memory is corrupt.


According to the error message ,I would like to suggest you to check the links below for the similar threads which provide some solutions for the same issue:

Hope it can help you.

Hello Ming,

i found the root cause of this error message. actually my OS is 64 bit and my dotnet application build on 32 bit and also the IIS where my application hosted was also 64 bit, that is why i used to get these error messages randomly.

Now, i changed my OS to 32 bit.

thank you.