.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal
Post New Web Links

Problem in accessing a PDF file in IIS 7.5

Posted By:      Posted Date: October 19, 2010    Points: 0   Category :.NET Framework

Hi Team,

I am trying to access a link in the ASP.NET page. This link should open a PDF file in browser. I have the handler configured to open the PDF file. Now the problem is that, since we have the space in the name of the file, i can see and HTTP 404 error coming up in the browser.

HTTP Error 400.0 - Bad Request

ASP.NET detected invalid characters in the URL.

Am i missing any setting specific to IIS / ASP.NET ?



View Complete Post

More Related Resource Links

Problem in accessing resource file dynamically.


Steps I have followed are
1.I have created myres.en-GB.resx file at C:.
2.then created locale specific myres.en-GB.resources using resgen at c: only,
resgen c:\myres.en-GB.resx
3.Linked the Resource File to Assembly using AL.exe which is giving me assembly at c: only.
Al /t:lib /embed:myres.en-GB.resources /out:ClassLibrary1.dll
4.I have created one web application using vs 2008 & then build it.
5.Then placed both resource file & dll in web applications Bin\en-GB folder.
6.Anf finally written code at page load like
 CultureInfo info = new CultureInfo("en-GB");
            Thread.CurrentThread.CurrentCulture = info;
            Assembly asd = Assembly.Load("ClassLibrary1");
            ResourceManager res = new ResourceManager("myres.en-GB", asd.GetSatelliteAssembly(info));
            string sdf = res.GetString("Lab1");

but after running application I m getting following error
MissingManifestResourceException", "Could not find any resources appropriate for the specified culture or the neutral culture. Make sure "Cla

While Importing Excel 2007 file to Datatable - headerrow problem


Hi there,


I am trying to simply extract an excel data from an uploaded file an put it into a datatable. In this case the excel file has 3 rows but when I fill the datatable I only see row count of 2.

I tried changing HDR:NO; to HDR:YES and vice versa, but no luck. 

What am I doing wrong? (Note: the excel file cannot have a  headerrow)


string connstr = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + pFilePath + ";Extended Properties=\"Excel 12.0;IMEX=1;HDR:NO;\"";
            OleDbConnection conn = new OleDbConnection(connstr);
            DataTable dtTables = conn.GetOleDbSchemaTable(System.Data.OleDb.OleDbSchemaGuid.Tables, null);
            string strTablename = dtTables.Rows[0]["TABLE_NAME"].ToString();
            string strSQL = "SELECT * FROM [" + strTablename + "]";

            OleDbCommand cmd = new OleDbCommand(strSQL, conn);

            DataTable dt = new DataTable();
            OleDbDataAdapter da = new OleDbDataAdapter(cmd);
            //At this point row count=2 which doesn't make sense




File Download Problem


Hi everyone,

I am using a download handler to handle the downloading of files from my website.  I am using a slightly modified code from the Microsoft article http://support.microsoft.com/kb/812406

Everything is working fine and downloading, even with large files, but it does not show the file size for any of the files to download. Even if theyre really small.

Here is my code for the handler

public class DownloadHandler : IHttpHandler

        public void ProcessRequest(HttpContext context)
            string path = "";
                path = context.Server.UrlDecode(context.Request.QueryString["src"]).DecryptString();
            catch(Exception ex)
            System.IO.Stream iStream = null;

            byte[] buffer = new Byte[10000];

            int length;

            long dataToRead;

            string filename = System.IO.Path.GetFileName(path);

                iStream = new System.IO.FileStream(context.Server.MapPath("~/" + path), System.IO.FileMode.Open,
                            System.IO.FileAccess.Read, System.IO.FileShare.Read);


Problem download file from SQL Server


Hello everyone. I am having an issue downloading files that I have store in SQL Server. I have no problem in a WinForm. What am I doing wrong in my code?

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        Dim sch As New clsReport
        Dim fileData As New clsReport.Letter
        fileData = sch.DownloadLetter(Session("LetterID"))
        Dim ms As System.IO.MemoryStream = fileData.fil

        Dim fil As Byte() = ms.ToArray
        Dim nam As String = fileData.name
        Dim ext As String = fileData.ext
        If Not fil Is Nothing Then
                ' Response.Clear()
                Response.AppendHeader("Content-Disposition", "attachment; filename=" + nam & "." & ext)
                ' Response.AddHeader("Content-Disposition", nam & "." & ext)
                Response.AddHeader("Content-Length", fil.Length.ToString)
                Response.ContentType = "Application/octet-stream"
                Response.Buffer = True
            Catch ex As Exception
            End Try

        End If

    End Su

Problem accessing Sharepoint 2007 MySite


My users are having an issue accessing their mysites.  When they go to the main portal page or any other site and click the link at the top right of the page to go to their Mysite they are thrown into an endless authentication loop.  If they cancel out of the loop the URL in the address bar is for http://mossserver/_layouts/MySites.aspx

For a user to successfully get to their myself they need to enter the full url like http://mossserver/personal/username/default.aspx

Now, I know somewhat how this happened.  It resulted from me trying to delete a user's mysite and I apparently did it wrong but I'm not sure what I did.  It almost seems like I deleted a redirect page or something...

Looking for any ideas.



Accessing Username, password, roles in xml file


Currently I am storing my username and password (passwordFormat="SHA1") credientails in my web.config.  I would like to figure out how to access them in an xml file that I have stored in my App_Data directory rather than the web.config file because I do not want my application restarting everytime I manually add a user (small list of 5 authorized users for the CMS section).

Here is what my web.config section looks like:


<authentication mode="Forms">
      <forms name=".Administration"

reading excel file problem



i have 200 rows in my excel file. im using OleDbConnection to read the excel file.

The problem is that it will read all the blank rows from row 200 onwards. Is there a configuration im missing ? or is there a way to import all rows that has data? Here's some of my code.

string excelConnectionString =
               "Provider=Microsoft.Jet.OLEDB.4.0;" +
                "Data Source=" + filePath + ";" +
                "Extended Properties=Excel 8.0";

OleDbConnection excelConnection =
                    new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + filePath + ";Extended Properties='Excel 8.0;HDR=NO'");

OleDbCommand cmd = new OleDbCommand("Select * from [list$]",excelConnection);

Generating MS Word doc from mht file gives smart quote problem


I have a word document to be generated using ASP.Net/VB.net.

So I have a word document template saved as .mht file on the web server.

In my ASP.Net code,I read this mht file content and replace certain string line Description$$ with the actual description from the database.Then save this content as .doc file.

This works fine but shows a box symbol when I have smart quotes " (not this one as I cannot type it here.The double quote which you see in MS Word,the slanted double quote).

I dont know how to make my word doc generated, show the exact double quote as in MS word.

If any of you have any idea of this please reply.

Thank you

Accessing file on remote server


       I need help to achieve the following.
       I have integrated the Single Sign On to my webapplication. Service Provider(SP) is developing in .net platform and windows server.Identity Provider (IdP) is configured in apache and linux server.
       For authentication I am redirecting the user to IdP and authenticate at IdP and return back to my .net website. So I have user's database in IdP as a db file user.db (see the apache configuration below) for authenticating user.
          <Location /idp/Authn/RemoteUser>
               AuthType Basic

Problem when using Activator.CreateObject and reading App.Config file

Hello, this is the scenario. I have an application that load at runtime severals dll. these dll are actually "adapters" that wraps calls to web services, database and so on. The app.config of the "main" application stores in config sections all information necessary to each adapter (i.e.Web ServiceURL..) and I have created inside each adapter a class to ready those values the loading at run time the DLL has been implemented by storing all necessary types into a dictionary of generics and when I need to instanciate it I call the Activate.CreateObject and I pass the specific type (I means the name of the Adapter class) The problem is that the adapter class itself is not able to get the config value because ConfigSection has not been initialized. If I write: IInterfaceAdap adapt = new myAdapter() -> I read the config data IInterfaceAdap adapt = (IInterfaceAdap)Activator.CreateObject (type) -> now way to read the data stored in the App.Config. I think that I undertood the problem but I'm not able to find a workaround to read data store in the app.config!! I need help please!!  

Problem in accessing datakeys

I have kept an int element and char element as datakeys of gridview,first one being the int element. But when I write the following code, error comes up stating that "Index was out of range. Must be non-negative and less than the size of the collection.Parameter name: index" Why does the error come up? and how to remove it? protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { Char s =Convert.ToChar(GridView1.DataKeys[e.Row.RowIndex][1]); if (s == '0') e.Row.BackColor = System.Drawing.Color.Red; else e.Row.BackColor = System.Drawing.Color.SeaGreen; }  

Web Folder problem : This file cannot be saved to this location because there is no connection to th

When I check out a Word 2007 document from a list, I cannot save it back to the server.  I get:   This file cannot be saved to this location because there is no connection to the server.  Check your network connection and try again.   I am using a Virtual Machine (Virtual PC).  I have the Microsoft Loopback adapter installed.    The server has a static IP address and is a domain controller. I am able to access the web folder through Windows Explorer.   How do I set up Office, Sharepoint and Webdav so that I can check files out of sharepoint and save them back, on a virtual machine?

File Upload Problem

I have a colleague that just cannot upload any files over 6mb to sharepoint. I have checked all his IE settings and everything is normal / the same as mine. anyone come across this before?Sharepoint Customiser

accessing MSSQLServer on Windows with Simple File Sharing

I am running MS SQL Server Developer Ed. on Windows XP SP3 in workgroup(non-domained). Having read  in [1]: "NTLM Authentication: Challenge- Response mechanism. In the NTLM protocol, the client sends the user name to the server; the server generates and sends a challenge to the client; the client encrypts that challenge using the user’s password; and the client sends a response to the server.If it is a local user account, server validate user's response by looking into the Security Account Manager; if domain user account, server forward the response to domain controller for validating and retrive group policy of the user account, then construct an access token and establish a session for the use." I could not understand: What happens in the case of "Use Simple File Sharing (Recommended)" (Windows Explorer --> Tools --> Folder Options --> View --> Use Simple File Sharing-->)? IS server validate Windows user accounts with passwords in "Windows Authentication" mode? In other words, is there need to create user accounts for accessing server? I have never used simple file sharing before... PS. Is this mode available on server editions of Windowses? [1] Understanding Kerberos and NTLM authentication in SQL Server Connections http://blogs.msdn.com/b/sql_protocols/archive/2006/12/02/understanding-kerberos-and-nt

SSIS multiple data flows accessing the same raw file

I have multiple data flow tasks accessing the same raw file at virtually the same time.  I would like to know if the data flow tasks lock the raw file during read?  Can multiple data flow tasks read the same raw file at the same time.  I'm currently developing with a very small data set, but I would like to know if I should be concerned with the possibility of the data flow tasks competing for access to the same raw file. Thanks.

Upload large file via webservice problem in vb.net 1.1

Hi All, I am uploading large file via webservice using below my code in vb.net 1.1. Problem is vb.net 1.1 don't know Using Object loop. I would like to know any other loop similar Using loop to replace in vb.net 1.1Public Function UploadLargeFile(ByVal FileName As String, ByVal buffer As Byte(), ByVal Offset As Long) As Boolean Dim retVal As Boolean = False Try Dim FilePath As String = Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory.ToString() & "\fpath\", FileName) If Offset = 0 Then File.Create(FilePath).Close() End If Using fs As New FileStream(FilePath, FileMode.Open, FileAccess.ReadWrite, FileShare.Read) fs.Seek(Offset, SeekOrigin.Begin) fs.Write(buffer, 0, buffer.Length) End Using retVal = True Catch ex As Exception Throw ex End Try Return retVal End Function  
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend