July 2013

Windows store privacy statement

I got the error from Microsoft while I was submit the app. The error is, “The app has declared access to network capabilities and no privacy statement was provided in the Windows Settings Charm.”

The sad part is that this is so easy to fix. First you will need to create a new directory Privacy and Page Control under it Privacy, it lives my pages/ directory. The page control Privacy creates the privacy.html, privacy.js and privacy.css files under Privacy folder.

My Privacy.Html Code is here

http://www.codeproject.com/Articles/292336/Silverlight-A-Beginners-Guide-for-Advanced-Develop<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title>privacy</title>

    <!-- WinJS references -->
    <link href="//Microsoft.WinJS.1.0/css/ui-dark.css" rel="stylesheet" />
    <script src="//Microsoft.WinJS.1.0/js/base.js"></script>
    <script src="//Microsoft.WinJS.1.0/js/ui.js"></script>

    <link href="privacy.css" rel="stylesheet" />
    <script src="privacy.js"></script>
</head>
<body>
    <!-- BEGINSETTINGSFLYOUT -->
    <div data-win-control="WinJS.UI.SettingsFlyout"
        id="privacyPolicy"
        data-win-options="{settingsCommandId:'privacyPolicy', width:'narrow'}">

        <div class="win-ui-dark win-header">
            <button type="button" onclick="WinJS.UI.SettingsFlyout.show()" class="win-backbutton"></button>
            <div class="win-label">Privacy Policy</div>
        </div>
        <div class="win-content">
            <p>
                This application does not collect any information about users. This
application also does not collect any username or password that users enter to authenticate.
            </p>
            <p>This privacy policy is subject to change without notice and was last updated on 22-July-2013. If you have any questions feel free to contact us directly at <a href="mailto:sales@eplannerpro.com">sales@eplannerpro.com</a>.</p>
        </div>
    </div>
    <!-- ENDSETTINGSFLYOUT -->
</body>
</html>

Now you just need a quick way to add this to your app. Add the following code in your default.js file:

 app.onsettings = function (args) {


        args.detail.applicationcommands = {
            "privacyPolicy": {
                title: "Privacy Policy", href: "/Pages/Privacy/privacy.html"
            }
        };
        WinJS.UI.SettingsFlyout.populateSettings(args);
    };

Now, run the app. Go to setting pane, click on Privacy, you will show the privacy statement.

How to add reference System.Web.Optimization

The Microsoft.Web.Optimization package is now obsolete. With the final release of ASP.NET (MVC) 4 you should install the Microsoft ASP.NET Web Optimization Framework:

Install the package from nuget:

Right click on References, Select Manage Nuget Packages. Type Microsoft.AspNet.Web.Optimization in search box and press enter you will get the package. Click on install.

Create and configure bundle(s) in App_Start\BundleConfig.cs:

public class BundleConfig
{
    public static void RegisterBundles(BundleCollection bundles) {
        bundles.Add(new ScriptBundle("~/Scripts/jquery").Include(
            "~/Scripts/Lib/jquery/jquery-{version}.js",
            "~/Scripts/Lib/jquery/jquery.*",
            "~/Scripts/Lib/jquery/jquery-ui-{version}.js")
        );

        bundles.Add(new ScriptBundle("~/Scripts/knockout").Include(
             "~/Scripts/Lib/knockout/knockout-{version}.js",
             "~/Scripts/Lib/knockout/knockout-deferred-updates.js")
        );
    }
}

Call the RegisterBundles() function from Application_Start() in your global.asax.cs:

using System.Web.Optimization;

protected void Application_Start() {
     ...
     BundleConfig.RegisterBundles(BundleTable.Bundles);
     ...
}

In your view.cshtml include the Optimization namespace and render the bundle(s):

@using System.Web.Optimization

@Scripts.Render("~/Scripts/jquery")
@Scripts.Render("~/Scripts/knockout")

HTTP Error 405.0 – Method Not Allowed error while trying to make a DELETE request to a .ashx

Here’s the final web.config section. The thing I needed to add I was missing was changing the staticFileHandler from using “all verbs” to all of them spelled out.

 <?xml version="1.0" encoding="utf-8"?>
<configuration>
  <appSettings>
    <add key="StorageRoot" value="C:\temp\"/>
  </appSettings>
  <system.web>
    <compilation debug="true" targetFramework="4.0" />
    <httpRuntime maxRequestLength="2147480000" executionTimeout="3600"/>
    <pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID"/>
   
  </system.web>
  <system.webServer>
   
    <modules>
      <remove name="WebDAVModule" />
    </modules>
    <handlers accessPolicy="Read, Write, Execute, Script">
      <remove name="StaticFile" />
      <remove name="SimpleHandlerFactory-ISAPI-2.0" />
      <remove name="WebDAV" />
      <remove name="SimpleHandlerFactory-Integrated-4.0" />
      <remove name="SimpleHandlerFactory-Integrated" />
      <add name="SimpleHandlerFactory-Integrated" path="*.ashx" verb="GET,HEAD,POST,DEBUG,PUT,DELETE" type="System.Web.UI.SimpleHandlerFactory" resourceType="Unspecified" requireAccess="Write" preCondition="integratedMode" />
      <add name="SimpleHandlerFactory-Integrated-4.0" path="*.ashx" verb="GET,HEAD,POST,DEBUG,PUT,DELETE" type="System.Web.UI.SimpleHandlerFactory" resourceType="Unspecified" requireAccess="Write" preCondition="integratedMode,runtimeVersionv4.0" />
      <add name="SimpleHandlerFactory-ISAPI-2.0" path="*.ashx" verb="GET,HEAD,POST,DEBUG,PUT,DELETE" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll" resourceType="Unspecified" requireAccess="Script" preCondition="classicMode,runtimeVersionv2.0,bitness32" responseBufferLimit="0" />
      <add name="StaticFile" path="*" verb="GET,HEAD,POST,DEBUG,PUT,DELETE" modules="StaticFileModule,DefaultDocumentModule,DirectoryListingModule" resourceType="Either" requireAccess="Read" />
    </handlers>
    <security>
      <requestFiltering>
        <requestLimits maxAllowedContentLength="2147480000"/>
      </requestFiltering>
      <authorization>
        <remove users="*" roles="" verbs="" />
        <add accessType="Allow" users="*" verbs="GET,HEAD,POST,PUT,DELETE,DEBUG" />
      </authorization>
    </security>
    <tracing>
      <traceFailedRequests>
        <remove path="*" />
        <add path="*">
          <traceAreas>
            <add provider="ASP" verbosity="Verbose" />
            <add provider="ASPNET" areas="Infrastructure,Module,Page,AppServices" verbosity="Verbose" />
            <add provider="ISAPI Extension" verbosity="Verbose" />
            <add provider="WWW Server" areas="Authentication,Security,Filter,StaticFile,CGI,Compression,Cache,RequestNotifications,Module,FastCGI" verbosity="Verbose" />
          </traceAreas>
          <failureDefinitions statusCodes="405" />
        </add>
      </traceFailedRequests>
    </tracing>
  </system.webServer>
</configuration>

Page not found 404 error in IIS 7 when uploading big file size

I struggled with one issue for hours, before realizing that IIS7 was the culprit. Even though maxrequestlength was set to 1GB in httpclientrequest (web.config) and executiontimeout was set to 600 seconds, for a larger file it would keep failing. Firebug was throwing a “404 not found” error for the handler.ashx!

IS has a security feature called requestFiltering, which is to prevent denial of service attacks. It sets the file size to 30MB maximum by default.
To change it, add the following to youor system.webServer section of web.config


   <security>
      <requestFiltering>
        <requestLimits maxAllowedContentLength="2147480000"/>
      </requestFiltering>
</security>	     
             

Here maxAllowedContentLength is set to 2 GB approx.

How To: Delete a Team Project from your Team Foundation Service collection

To delete a team project from your Team Foundation Service collection you will need Visual Studio 2012 (or just Team Explorer 2012, which is free here). These provide you with the “tfsdeleteproject.exe” command line tool, which is usually located in C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE. Open a Command Prompt in that folder and then run the delete command like this (don’t forget the “/DefaultCollection” bit and remember to use quotation marks around your team project name if it has spaces in it).

tfsdeleteproject.exe /force /collection:https://.VisualStudio.com/DefaultCollection “My project name with spaces”