Friday 13 March 2015

Large File Upload causing issue in IIS(" Default will be 30 mb ")

1. Modify the maxAllowedContentLength setting in the web.config



<system.webServer>

  <security>
    <requestFiltering>
      <requestLimits maxAllowedContentLength="2147483648" />
    </requestFiltering>
  </security>
</system.webServer>

                                  OR

2. Edit the request filtering feature settings and the request limits using IIS manager

  1. Open IIS Manager.
  2. Select the website that you want to configure.
  3. Make sure you are in Features View per the button at the bottom of the manager.
  4. Select Requests Filtering and open it by double-clicking the icon. The Request Filtering pane displays.
  5. From the Actions pane on the right hand side of the screen click Edit Feature Settings... link. The Edit Request Filtering Settings window displays.
  6. In the Request Limits section, enter the appropriate Maximum allowed content length (Bytes) and then click the OK button.
  7. Restart IIS.

Useful Shortcut Key For VS Debugging

Shortcut KeysDescriptions
Ctrl-Alt-V, ADisplays the Auto window
Ctrl-Alt-BDisplays the Breakpoints dialog
Ctrl-Alt-CDisplays the Call Stack
Ctrl-Shift-F9Clears all of the breakpoints in the project
Ctrl-F9Enables or disables the breakpoint on the current line of code
Ctrl-Alt-EDisplays the Exceptions dialog
Ctrl-Alt-IDisplays the Immediate window
Ctrl-Alt-V, LDisplays the Locals window
Ctrl-Alt-QDisplays the Quick Watch dialog
Ctrl-Shift-F5Terminates the current debugging session, rebuilds if necessary, and starts a new debugging session.
Ctrl-F10Starts or resumes execution of your code and then halts execution when it reaches the selected statement.
Ctrl-Shift-F10Sets the execution point to the line of code you choose
Alt-NUM *Highlights the next statement
F5If not currently debugging, this runs the startup project or projects and attaches the debugger.
Ctrl-F5Runs the code without invoking the debugger
F11Step Into
Shift-F11Executes the remaining lines out from procedure
F10Executes the next line of code but does not step into any function calls
Shift-F5Available in break and run modes, this terminates the debugging session
Ctrl-Alt-HDisplays the Threads window to view all of the threads for the current process
F9Sets or removes a breakpoint at the current line
Ctrl-Alt-W, 1Displays the Watch 1 window to view the values of variables or watch expressions
Ctrl-Alt-PDisplays the Processes dialog, which allows you to attach or detach the debugger to one or more running processes
Ctrl-D,VIntelliTrace Event

Sunday 1 March 2015

Kindly don’t use “Directory.Move” and ”File.Move” to handle files, always copy the files to another location and on success delete from the current location.

Directory.copy is not available as of now (.net 4.0) so use the below function.

public static void copyDirectory(string Src, string Dst)
        {
            String[] Files;
            if (Dst[Dst.Length - 1] != Path.DirectorySeparatorChar)
                Dst += Path.DirectorySeparatorChar;
            if (!Directory.Exists(Dst)) Directory.CreateDirectory(Dst);
            Files = Directory.GetFileSystemEntries(Src, "*.pdf");
            foreach (string Element in Files)
            {
                try
                {
                    File.Copy(Element, Dst + Path.GetFileName(Element), true);
                }
                catch (Exception)
                {
                    continue;
                }
            }
        }



                And it is better to handle delete in a separate function like.
      
        DeleteDirectory(Folderpath);

        protected void DeleteDirectory(string iDirectory)
        {
            try
            {
                Directory.Delete(iDirectory);
            }

            catch
            {

            }

        }