顯示具有 IIS7 標籤的文章。 顯示所有文章
顯示具有 IIS7 標籤的文章。 顯示所有文章

ASP.NET - file path too long exception

Error message:

Server Error in '/' Application.

The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.IO.PathTooLongException: The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters.
Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

 

Solution :

web.config append the following configuration at


<system.web>
…
<httpRuntime maxUrlLength="1000" relaxedUrlToFileSystemMapping="true" />
…
</system.web>

Enable IIS Failed Request Tracing

Step 1: Enable windows feature :  Internet Information Services >  World Wide Web Services  > Health and Diagnostic > Tracing

Step 2: Open IIS Manage > Go to your site >  click 'Failed Request Tracing...’ on actions pane > Click 'enable'.

Step 3: In the features view, click 'Failed request tracing rules'.  Click add and choose your purpose like below :

a : Selected ‘All Content (*)’ , Status Code(s) : 200 

b:  Selected ‘ASP.NET (*.aspx) , Staus Code(s) : 401-999 , Event severity : Error

c:  Selected ‘Custome : *.js’ , Status Code(s) : 200

Step 4 : Look in c:\inetpub\logs\FailedReqLogFiles\w3svcX\

Windows command – backup & remove all IIS log

  1. Download Source code by package (must) ,  Unzip BackupLog Folder to C:\  (Total 5 files: 7z.dll , 7z.exe , ufind.exe,  BackupLog.bak, BackupLog_Chinese.bak)
  2. Download sample batch (must) based on date and time format.  US or Chinese
    Chinese format , US Format
  3. Check your IIS Log path location was under the “C:\inetpub\logs\LogFiles”  , if not please modify sample batch or modify the parameter whatever you want.
  4. [Option] Setting task scheduler run the batch file
Dropbox share link OR Download Source code by package

A Friendly remind: If choose task scheduler to perform batch job, please ensure the account log-in on the server once and had permission on log folder.

IIS 7 To export/import a single website

Step1 Export:
%windir%\system32\inetsrv\appcmd list site “MyWebsite” /config /xml > c:\mywebsite.xml

Step2 Hack xml:
Hack name & id attributes in second site element , c:\mywebsite.xml

e.g.
<site name="mywebsite" id="1" serverAutoStart="true">
to
<site name="mywebsite2" id="2" serverAutoStart="true">

Step3 Import:
%windir%\system32\inetsrv\appcmd add site /in < c:\mywebsite.xml

Reference: :http://www.microsoftpro.nl/2011/01/27/exporting-and-importing-sites-and-app-pools-from-iis-7-and-7-5/


Note for purpose of create new website and keep original website

  1. Manually add new application pool & set new applicationPool to your website.
  2. Set attribute of serverAutoStart to “false”
  3. Set new attribute to bindingInformation.

[IIS7] log entries for a specific web site

 

  1. Click on the Web Site (Default Web Site) > Right click and hover to Manage Web Site, click on Advanced Settings > Find ID

    ID = 1
  2. Click on the Web Site (Default Web Site) > Features View double click on Logging icon > Find Directory 

Directory = %SystemDrive%\inetpub\logs\LogFiles

The file path must be under the

%SystemDrive%\inetpub\logs\LogFiles\W3SVC1