Blocking sites with the SonicWall TZ-205 Content Filtering Service (CFS)

January 10, 2014 at 2:07 PMMadestro


I recently installed a SonicWall TZ-205 on a customer site without a CGSS subscription.

The customer wanted to block some websites. I went to Security Services > CFS and set up a custom list of websites. This functionality still works, even without a subscription.

When I went to apply the policy to the zones however, I got stuck because the combo box used to display the policies was empty. From every tutorial out there, I was expecting to see a "default policy" entry. 

Testing the unit by just checking the "Enable Content Filtering" box didn't work. I could still see the offending site.

It turns out the appliance is smart enough to know NOT to block ME while I am logged in as admin. After I logged out, I tried hitting one of the offending sites and behold!... it worked.

Posted in: Windows Networking


Intellisense not working on views after migrating MVC application to Visual Studio 2013

January 8, 2014 at 11:28 AMMadestro


I recently migrated one of our MVC applications to Visual Studio 2013.

After the migration, Intellisense broke. It would not work for any view I opened. It wouldn't even recognize the @model directive.

Since part of the plan was to upgrade to the latest version of MVC (5 at the time of this writing), I decided to add the NuGet package and its dependencies. This didn't solve the problem either.

Eventually, I ended up creating a new test MVC project with Visual Studio 2013. I then took the pertinent sections from the web.config file under the Views folder and copied them over to my migrated project. I then closed and relaunched VS2012 and the solution.

That got Intellisense working again.

Keep in mind that if you do this, you will introduce some new dependencies, since the latest template uses the System.Web.Optimization namespace. I didn't try removing this namespace from the web.config but if you don't want the dependencies, you might be able to get away with removing it from the web.config.

Posted in: ASP.NET MVC | Visual Studio


Removing SVN from a Visual Studio 2012/2013 Solution

January 7, 2014 at 3:59 PMMadestro


I recently ran into a situation while trying to migrate a project from SVN to TFS.

I used the Export command of Tortoise SVN to produce the output I would migrate. This effectively produces a "clean" copy of the code (no SVN folders).

When I tried to add the code to TFS via Visual Studio, I noticed the solution kept loading with SVN bindings (I use the ANKHSVN plugin). If I tried to switch the plugin, it would ask me to close the solution.

I went poking around in the Solution (.sln) file and found the following entry:


GlobalSection(SubversionScc) = preSolution

Svn-Managed = True

Manager = AnkhSVN - Subversion Support for Visual Studio



Removing this "GlobalSection" did the trick for me. After launching the solution again, I was able to add it to TFS.

I hope this helps anyone with the same issue out there.

Posted in: Visual Studio


Getting an XSLT file to load when the site is hosted on a network share

November 25, 2013 at 10:53 AMMadestro

So I was working on a website the other day and had a bunch of XSLT templates that were used to produce HTML for e-mails.

Well, no e-mails were coming through. Further investigation revealed the issue to be that the XslCompiledTransform.Load() method call was failing with a System.IO.FileNotFound error.

When I looked at the  actual physical path for the file that resulted from the call to Server.MapPath(), I realized that the site was actually being hosted on a network share (e.g. \\someserver\sites\x\content\web\xsltfile.xslt)

 The issue in this case turned out to be Network Access permissions.

 You see, the issue with this setup is that the application pool runs under a particular identity (e.g. NetworkService). Because the file we are trying to read actually seats on a NETWORK share, the account the pool is running in does not have permissions to read the file so we need to authenticate. Unfortunately the error thrown is misleading since the path is correct. It's just that it cannot reach the file due to permissions.

There are ways in which you can perform authentication but that involves internal knowledge of the network share and more times than not it is less than ideal since most people use a hosting provider.

And then, after being transferred four times to someone else by RackSpace support, it hit me!...

If you keep your XSLT files within the public realm of your website, you can have it served to you by the web server.

In other words, simply consume it as a web resource. The XslCompiledTransform.Load() method supports a URI as a parameter (or string representing one):

string sampleAddress = "";
XslCompiledTransform transform = new XslCompiledTransform();


And that's all there is to it. Laughing

Posted in: ASP.NET MVC


Visual Studio publishing error: The specified file could not be encrypted

August 22, 2013 at 3:20 PMMadestro

I was trying to publish a web application the other day and came across an interesting error with some of the files:

The specified file could not be encrypted.

The solution turned out to be pretty simple:

1. Go to each file (or folder) giving you issues

2. Right click and select Properties

3. Hit the Advanced button

4. Uncheck "Encrypt contents to secure data"

5. Click OK, then OK on the other dialog (or APPLY)

6. Open (or preview) any file in the folder giving you issues

So why does this happen?

If Windows is storing your files in encrypted form, when the publish process attempts to copy the file, it tries to encrypt the file again and you get this error.

After clearing the encryption from the files, I was still experiencing the issue. It then occurred to me that the files might not get "decrypted" until I open them again which seems to be the case.

Maybe there is another reason but the bottom line is that opening them after unchecking the box in the properties made it work for me.

Good luck!

Posted in:


EF error: OriginalValues cannot be used for entities in the Added state

August 19, 2013 at 5:23 PMMadestro

I was working on a repository and came across an interesting, cryptic error that resulted from a fairly simple operation: Saving the changes.

Without getting into code details (which are  irrelevant to the point), the call to the following statement failed:


The error message read: OriginalValues cannot be used for entities in the Added state

The issue turned out to be that I had a field of type DateTime on SQL server that was set to NOT NULL. I forgot to assign the value to the entity field before calling SaveChanges() which resulted in a default DateTime value on the entity that was being passed on to SQL. This value was outside the range of valid SQL date values. 

Once I set the value on the field, the call to SaveChanges() completed without a problem.

I have been doing some more research on the subject and my understanding so far is that this situation can also be encountered if you have fields with default values on SQL Server. Because EF does not know about these default values, even if they exist, EF will force the value from the entity (like in my case), including situations where you have a value of NULL.

If anyone else can shed more light on the subject, please feel free to comment.


Posted in: Entity Framework


Why are my bootstrap scripts not rendering in MVC4?

May 1, 2013 at 2:59 PMMadestro

I recently decided to play with Bootstrap, a front-end framework for creating websites that are responsive to the type of device used to access them.

I was following an article I found in .NET Curry and everything was going well. For anyone new to Bootstrap, here is a quick overview of the steps to add Bootstrap to an ASP.NET MVC4 application:

  • Add Bootstrap NUGET package to MVC4 application
  • Update jQuery to the required version
  • Add Bootstrap bundles in BundleConfig.cs
  • Modify _layout.cshtml to include Bootstrap scripts and styles
  • Modify _layout.cshtml with the wireframe of your new Bootstrap design
  • Modify your pages based on Bootstrap

(Read the full article for details)

Strangely enough, the styles were not being applied. I did everything the article said!... why is it not working?...

Further examination revealed the Bootstrap scripts and CSS was not being outputted to the page.

After Googling for a while, I found the answer in StackOverflow.

It turns out the BundleCollection class (passed on as a parameter to the BundleConfig class from the Global.asax call) has an IgnoreList property which is an instance of the IgnoreList class that defines items or patterns to ignore. 

Conveniently (or not so) enough, it ignores the ".min" pattern. 

The solutions:

  1. Remove the .min from the script and style paths added in the BundleConfig.cs class, OR
  2. Call the Clear() method of the IgnoreList instance in order to remove the filters:
    • bundles.IgnoreList.Clear();

This will cause your Bootstrap scripts and styles to render as they should.

One more note for those of you getting started with Bootstrap:

Applying the NUGET package only adds the files needed to run bootstrap. It won't magically change your layout and/or pages. Once you get Bootstrap running, go get yourself a page design and/or theme and modify your pages accordingly.

Posted in: ASP.NET MVC


Getting Ajax calls to work with MVC4

January 31, 2013 at 4:18 PMMadestro

I recently started working with MVC4. After (literally) cutting and pasting code from some other application I had worked on which used MVC3, I found my Ajax calls where no longer working. 

It took me about three hours of research to figure out what the issue was.

The JQuery libraries that are used for Ajax calls are loaded in a different manner now. In the past, you would include them one by one in your _layout file. With the new version, you need to introduce the right "bundle". 

If you look at the code generated by the VS template, you will see two calls that load stuff for you:


What you need to do is add the following two lines of code in order to load the JQuery includes:


What's happening under the scenes is that there is now a new Bundle and Minification Framework in place. If you look at your App_Start folder, you will notice a file called BundleConfig.cs. This file contains bundle definitions that are used to load resources. You can read more about it here.

The bundle in question here is defined as follows:

bundles.Add(new ScriptBundle("~/bundles/jqueryval").Include(

Once these two files are loaded, your Ajax calls should start working again.

Hopefully this post will save you some Google time... you can find the source that solved my issue here.

Posted in: ASP.NET MVC


SEO Keyword Madness... No More

January 28, 2013 at 1:44 PMMadestro

Back in April, Google updated their algorithms so that pages overloaded with relevant keywords actually rank lower. Now they are officially warning against this practice in their guidelines.

On top of that, encrypted search (when you get the "not provided" keyword entry in the reports) has essentially made keyword reporting unreliable.

If you are interested in the details, you can read the full article from Starpoint Marketing here.

That's right. Finally, no more meaningless garbage designed to generate more hits!

More meaningful content, more elegant content. That's the way it should be.

Posted in: SEO


How to change an identity column value in SQL

April 3, 2012 at 10:14 AMMadestro

It's not very obvious to the non-db-admin type but you can't just override an identity value in a table, even if you set identity_insert ON.

What you need to do instead is:

  • Turn identity_insert ON
  • Delete the record you need to change
  • Insert it again with the desired identity value
  • Turn identity_insert OFF

Here is the code snippet:

INSERT INTO YOUR_TABLE (YOUR_IDENTITY_FIELD, ...[other fields]) VALUES (THE_NEW_ID,  ...[other fields])

Posted in: Databases