Compiled Spam

March 12, 2015

We encountered the unprocessed spam template nearly 2 years ago.

And now there’s the compiled processed spam comment, which seems to include every spam comment ever posted in just 1 comment. Hooray!

I’m excited to uncover this great site. I want to to thank you
for your time due to this wonderful read!! I definitely appreciated every little bit of it and i also have you saved as a favorite to look at
new stuff in your site.

May I simply say what a comfort to find somebody that genuinely
knows what they’re discussing on the web.
You certainly know how to bring a problem to light and make it important.
More and more people really need to check this out and understand this side of the story.
I was surprised that you’re not more popular since
you most certainly possess the gift.

Excellent post. I absolutely appreciate this site.
Continue the good work!

It’s hard to find knowledgeable people on this topic, however, you seem like you know what you’re talking
about! Thanks

You should take part in a contest for one of the best sites on the internet.
I will highly recommend this blog!

An intriguing discussion is worth comment. There’s no doubt that that you should write more
about this issue, it might not be a taboo matter but generally people do
not discuss these subjects. To the next! Cheers!!

Hello there! I just want to offer you a huge thumbs up for your excellent
information you’ve got here on this post. I will be coming back to your web site for more soon.

After I initially left a comment I seem to have
clicked on the -Notify me when new comments are added- checkbox and now
whenever a comment is added I get four emails with the exact same
comment. Is there an easy method you are able
to remove me from that service? Cheers!

Next time I read a blog, Hopefully it does not disappoint me as much as
this one. After all, Yes, it was my choice to read, nonetheless I genuinely thought you’d have
something helpful to say. All I hear is a bunch of moaning about something you could fix if you weren’t too busy seeking
attention.

Spot on with this write-up, I absolutely believe this
website needs a lot more attention. I’ll probably be back again to see more, thanks for the
information!

You’re so awesome! I do not think I’ve read through
something like that before. So good to discover somebody with some
unique thoughts on this subject. Seriously.. thanks for starting this up.
This website is one thing that is needed on the internet, someone with a little originality!

I love reading through an article that can make men and women think.

Also, many thanks for permitting me to comment!

This is the perfect blog for everyone who wishes to
understand this topic. You realize so much its almost tough to argue with you (not that I actually would want to…HaHa).

You certainly put a new spin on a subject that’s been discussed for ages.
Wonderful stuff, just great!

Aw, this was an exceptionally good post. Taking a few minutes and actual effort to create a great article… but what can I say… I put things off a whole
lot and never seem to get nearly anything done.

I’m impressed, I must say. Seldom do I encounter a blog
that’s both educative and entertaining, and without a
doubt, you’ve hit the nail on the head. The problem is something that too few folks are
speaking intelligently about. Now i’m very happy I came across this in my
search for something regarding this.

Oh my goodness! Amazing article dude! Thanks, However I am experiencing issues with your RSS.

I don’t understand why I cannot join it. Is there anyone else
having similar RSS problems? Anyone that knows the answer can you
kindly respond? Thanx!!

An outstanding share! I’ve just forwarded this onto a friend who was conducting
a little research on this. And he actually ordered me lunch
simply because I discovered it for him… lol. So let me reword this….

Thank YOU for the meal!! But yeah, thanx for spending time to talk about this matter here on your website.

After looking into a handful of the articles on your web site,
I honestly like your technique of blogging. I saved
as a favorite it to my bookmark website list and will be checking back in the
near future. Take a look at my web site too and tell me what you think.

This site truly has all of the info I wanted concerning this subject and didn’t know who to ask.

There’s certainly a lot to know about this subject.

I really like all of the points you made.

You have made some good points there. I looked on the web for additional information about the issue and found most people
will go along with your views on this website.

Nice post. I learn something totally new and challenging on blogs I stumbleupon on a daily basis.
It will always be helpful to read through articles from other writers and practice something from other websites.

I blog often and I genuinely appreciate your content. This article has really peaked my interest.
I’m going to book mark your blog and keep checking for new details about once a week.
I opted in for your Feed as well.

Pretty! This has been an incredibly wonderful post.
Thanks for supplying these details.

Greetings! Very useful advice in this particular post!

It’s the little changes which will make the biggest changes.
Many thanks for sharing!

Howdy! This blog post could not be written any better!

Looking through this article reminds me of my previous roommate!
He always kept talking about this. I will send this information to him.

Fairly certain he will have a great read. Thanks for sharing!

Howdy, I think your site could be having web
browser compatibility issues. Whenever I look at your web site in Safari,
it looks fine however, when opening in Internet Explorer, it has some overlapping issues.
I merely wanted to give you a quick heads up! Apart from that, wonderful website!

Having read this I thought it was really informative.
I appreciate you taking the time and effort to put this content together.
I once again find myself personally spending a significant amount of time both reading and commenting.

But so what, it was still worth it!

Hi there! I could have sworn I’ve visited this site before but after browsing through many of the posts I realized it’s new to me.
Anyhow, I’m definitely happy I stumbled upon it and I’ll be bookmarking it and checking
back regularly!

I want to to thank you for this very good read!! I certainly
loved every little bit of it. I’ve got you book-marked to look at
new stuff you post…

Hi, I do believe this is an excellent site. I stumbledupon it ;) I am going to return yet again since i have book-marked it.
Money and freedom is the greatest way to change, may you be rich and continue to help others.

Your style is unique compared to other people I’ve read stuff from.
Many thanks for posting when you’ve got the opportunity,
Guess I will just book mark this web site.

I used to be able to find good advice from your blog posts.

Very good post! We will be linking to this great post on our website.

Keep up the good writing.

That is a very good tip particularly to those fresh to the blogosphere.
Simple but very accurate info… Many thanks for sharing
this one. A must read article!

I could not refrain from commenting. Perfectly written!

bookmarked!!, I really like your website!

Very good article. I am experiencing a few of these issues as well..

Way cool! Some very valid points! I appreciate you writing this write-up plus
the rest of the website is very good.

Great web site you have got here.. It’s hard to find
good quality writing like yours these days. I really appreciate people
like you! Take care!!

This is a topic that’s near to my heart…
Cheers! Exactly where are your contact details though?

I truly love your website.. Pleasant colors & theme.
Did you create this site yourself? Please reply back as I’m
attempting to create my own personal site and want to know where you
got this from or just what the theme is named.

Appreciate it!

I really like it when people get together and share thoughts.
Great website, stick with it!

Very good info. Lucky me I recently found your blog by chance (stumbleupon).
I’ve book-marked it for later!

This blog was… how do you say it? Relevant!!
Finally I’ve found something that helped me. Appreciate it!

Everything is very open with a clear clarification of the
challenges. It was really informative. Your site is
very useful. Many thanks for sharing!

I would like to thank you for the efforts you’ve put in penning this blog.
I am hoping to see the same high-grade content from you in the
future as well. In fact, your creative writing abilities has
motivated me to get my own, personal site now


Avoiding repetitive code using Actions and Funcs

March 12, 2015

Some coding guidelines require that functions follow a pre-defined scheme, such as

  • log function begin
  • execute function
  • log function end
  • exception handler
  • log exception

to name just the simplest structure.

Since repetitive code is prone to errors, it’s a good idea to encapsulate these steps in a method which in turn calls the “execute function” step.

An example from an MVC project:

public ActionResult Method() {
  logger.Info("begin method");

  try {
    var user = CurrentUser();
    var data = DoSomething(user);
    logger.Info("end method");
    return View("View", data);
  }
  catch (Exception ex) {
    logger.Error("method exception", ex);
    throw;
  }
}

We can now extract most of the code into a common method

protected ActionResult Execute(string actionName, 
  Func<User, ActionResult> action) {
  logger.Info("begin " + actionName);

  try {
    var user = CurrentUser();
    var result = action(user);
    logger.Info("end " + actionName);
    return result;
  }
  catch (Exception ex) {
    logger.Error(actionName, ex);
    throw;
  }
}

so that the original method can be reduced to

public ActionResult Method() {
  return Execute("method", (user) =>
  {
    var data = DoSomething(user);
    return View("View", data);
  });
}

Deploying ASP.Net MVC 5 on Windows Server 2008

December 5, 2014

Developing an MVC application in Visual Studio 2013 (Update 3), I needed to install a demo on a Windows 2008 server.

Since Server 2008 ships with .Net 3, we first need to install .Net 4.5.1, either from the Visual Studio download page, or from MSDN.

After the required reboot and setting up a web application in IIS, browsing to the new site resulted in HTTP errors 403 (refers to directory browsing) and 404 (when navigating to a specific controller action).

Luckily, this issue could be solved by re-adding <modules> to the <system.webServer> section (found on SO):

<system.webServer>
  <modules>
    <remove name="UrlRoutingModule-4.0" />
    <add name="UrlRoutingModule-4.0" 
        type="System.Web.Routing.UrlRoutingModule" 
        preCondition="" />
  </modules>
</system.webServer>

After editing the web.config, the web application could be accessed, but all CSS and JavaScript requests, which are served using Bundling and Minification, would result in a 404.

Again, another module wanted to be included

      <remove name="BundleModule" />
      <add name="BundleModule" type="System.Web.Optimization.BundleModule" />

Finally, the web application looked as expected, so I logged in, and

No owin.Environment item was found in the context.

The internets are full of helpful tips to add

<add key=”owin:AppStartup” value=”[Namespace].Startup, [AssemblyName]” />

but that did not change anything. What really solved that last problem was to add the attribute

<modules runAllManagedModulesForAllRequests="true" />

in web.config.

In the end, the web.config section looks like this

  <system.webServer>
    <modules  runAllManagedModulesForAllRequests="true">
      <remove name="FormsAuthentication" />
      <remove name="UrlRoutingModule-4.0" />
      <add name="UrlRoutingModule-4.0"
          type="System.Web.Routing.UrlRoutingModule" 
          preCondition="" />
      <remove name="BundleModule" />
      <add name="BundleModule" 
          type="System.Web.Optimization.BundleModule" />
    </modules>

Remove Unused References with Visual Studio 2013

December 3, 2014

My favorite reference removal tool, Reference Assistant, only target Visual Studio 10 (2010) and 11 (2012), according to the description.

To install it in VS 2013, you need to follow the tips given on the Q&A tab of the assistant’s page on the Visual Studio Gallery:

So, the manifest file in this extension has a typo, which is why it wont install in VS2013. Change the vsix file to .zip, unzip it, edit the manifest file for the installationtargets from “[11.0,12.0)” to “[11.0,12.0]” and save it. Select all the files and zip it up. Rename the zip file to .vsix again and install.

If you follow those instructions literally,

  • rename the .vsix to .zip
  • unzip the .zip
  • edit the extension.vsixmanifest file
  • replace every instance of
InstallationTarget Version="[11.0,12.0)"

with

InstallationTarget Version="[11.0,12.0]"
  • save the file
  • zip all files
  • rename the .zip to .vsix

then the modified vsix can be installed in VS2013.

When I first tried it (by not following exactly), I simply dragged the .vsixmanifest file out of the .zip, edited it, and then moved it back into the .zip using Windows Explorer, I actually received the error message reported in the Q&A:

Microsoft.VisualStudio.ExtensionManager.InvalidExtensionPackageException:
The file is not a valid VSIX package.
---> System.IO.FileFormatException: File contains corrupted data.

Good to have the tool in the latest version of VS as well ;)


Fixing “The type ‘System.Web.Mvc.***’ is defined in an assembly that is not referenced.”

November 19, 2014

In Visual Studio 2010, I tried to compile an ASP.Net MVC 3 project that I have been working on for months, and suddenly received the error messages

The type ‘System.Web.Mvc.IAuthorizationFilter’ is defined in an assembly that is not referenced. You must add a reference to assembly ‘System.Web.Mvc, Version=3.0.0.1, Culture=neutral, PublicKeyToken=31bf3856ad364e35′.

The type ‘System.Web.Mvc.FilterAttribute’ is defined in an assembly that is not referenced. You must add a reference to assembly ‘System.Web.Mvc, Version=3.0.0.1, Culture=neutral, PublicKeyToken=31bf3856ad364e35′.

Turns out that by installing Visual Studio 2013 (or one its product updates) switches from 3.0.0.0 to 3.0.0.1, as a quick glance in the .csproj reveals:

<Reference Include="System.Web.Mvc, Version=3.0.0.0, Culture=neutral, 
    PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />

versus

<Reference Include="System.Web.Mvc, Version=3.0.0.1, Culture=neutral, 
    PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />

By removing the reference and re-adding it, the solution compiled again successfully.


Custom XSD Validation in Visual Studio 2013

November 6, 2014

We developed an XSD schema, and wanted to create valid .cshtml markup using Visual Studio.

Based on tips found on the internet, I managed to get this working on VS2010 (sorry, didn’t write about it ;) ), but for VS2013, the solution seems to be different again.

Here’s how I managed to get custom XSD validation in VS2013:

  • Put a copy of your XSD in the directory
C:\Program Files[ (x86)]\Microsoft Visual Studio 12.0\Common7\Packages\schemas\html
  • Open regedit.exe and navigate to the key
HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\12.0_Config\Packages\{1B437D20-F8FE-11D2-A6AE-00104BCC7269}\Schemas

This reg key holds all schemas for the VS “package” Visual Studio HTM Editor Package”.

The value of “File” is the relative path to the .xsd, in our case “html\my.xsd”.

  • Add a string named “Friendly Name”

The value of “Friendly Name” is the name to be displayed in the validation settings.

  • Add a DWord named IsBrowseable

Not sure whether this is required, but HTML5 and XHTML5 also have it. Set its value to 1.

Alternatively, you can also create a .reg file, set the values according to your environment, and import using regedit:

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\12.0_Config\Packages\{1B437D20-F8FE-11D2-A6AE-00104BCC7269}\Schemas\http://tempuri.org/my.xsd]
"File"="html\\my.xsd"
"Friendly Name"="My Schema"
"IsBrowseable"=dword:00000001

Start Visual Studio 2013, and navigate to Tools, Options, Text Editor, HTML (Web Forms). Or simply type “valid” in the search box of the Options dialog.

You will find your entry “My Schema” in the dropdown list “Target when no doctype found:”.

If you only want to edit files confirming to your schema, then select it here.

Otherwise, close the dialog, and right-click the toolbar (right below the menu bar) and check the item “HTML Source Editing”. Now the toolbar will also contain the Target Schema selection dropdown.

BUT: If you open a .cshtml by double-clicking, the source will be displayed, but the Target Schema dropdown is inactive!

The reason is that, whoever invented this whole thing, there is a difference between “HTML Editor” and “HTML (Web Forms) Editor”!

Right-click the .cshtml file, and select “Open With…”. In my installation, HTML Editor is the default for .cshtm, but you can set the Web Forms editor as default using the, uhm, “Set as Default” button.

So now, either way you open the .cshtml in the “HTML (Web Forms) Editor”, the Target Schema selection dropdown is now active, and your custom schema can be selected for validation.

Unfortunately, Razor does not seem to be supported in the Web Forms Editor (high-lighting etc), so you need to choose between Razor-enabled unvalidated or Razor-disabled validated editing. Really?

Sources: SO, AngularJS, MSDN Social.


Browser Screenshot Tools

October 16, 2014

In my previous blog on browser screenshot extensions I did not cover Internet Explorer.

For two reasons: I do not use IE frequently, and therefore I had no experience with screenshot add-ons or plugins.

But now I across a screenshot tool called Greenshot. It’s not a browser extension, but rather a stand-alone program sitting in the Windows Toolbar, which lets you take a screenshot of the current window.

It offers special commands for IE, so that it also scrolls IE’s windows while taking a screenshot.

The default file name is derived from the window’s title and the current timestamp, but the file name format can be configured, and the file name can be changed in the File Save dialog.


Follow

Get every new post delivered to your Inbox.

Join 76 other followers