Check this out :
https://code.google.com/p/elmah/
Dec 22, 2015
Nov 4, 2015
RePost - AsQueryable vs AsEnumerable
Important difference between casting and converting !
http://stackoverflow.com/questions/17968469/whats-the-differences-between-tolist-asenumerable-asqueryable
http://stackoverflow.com/questions/17968469/whats-the-differences-between-tolist-asenumerable-asqueryable
Oct 16, 2015
ASP.NET MVC routing ordering
Always place more specific route before less specific in your routes definitions ....
And I always forget it.
More specific route includes your parameters and so :
routes.MapRoute("ReportsWithoutMISCode",
"Reports/{Action}/{programObjectiveId}/{userName}",
new { controller = "Reports", action = "Index" },
new { programObjectiveId = @"\d+" },
new[] { "Web.Controllers.Reports" });
routes.MapRoute("ReportsWithMISCode",
"Reports/{Action}/{programObjectiveId}/{userName}/{MISCode}",
new { controller = "Reports", action = "Index" },
new { programObjectiveId = @"\d+" },
new[] { "Web.Controllers.Reports" });
; should be switched since second route ReportsWithMISCode is more specific, means having more parameters.
So it should be:
routes.MapRoute("ReportsWithMISCode",
"Reports/{Action}/{programObjectiveId}/{userName}/{MISCode}",
new { controller = "Reports", action = "Index" },
new { programObjectiveId = @"\d+" },
new[] { "Web.Controllers.Reports" });
routes.MapRoute("ReportsWithoutMISCode",
"Reports/{Action}/{programObjectiveId}/{userName}",
new { controller = "Reports", action = "Index" },
new { programObjectiveId = @"\d+" },
new[] { "Web.Controllers.Reports" });
It is interesting to note that in first case route works in awkward way. It gets matched but third parameter MISCode is appended as query param with question mark like this:
...ReportXXX/101/pt2?MISCode=MyMISCode
After switching to second solution we get friendly url.
And I always forget it.
More specific route includes your parameters and so :
routes.MapRoute("ReportsWithoutMISCode",
"Reports/{Action}/{programObjectiveId}/{userName}",
new { controller = "Reports", action = "Index" },
new { programObjectiveId = @"\d+" },
new[] { "Web.Controllers.Reports" });
routes.MapRoute("ReportsWithMISCode",
"Reports/{Action}/{programObjectiveId}/{userName}/{MISCode}",
new { controller = "Reports", action = "Index" },
new { programObjectiveId = @"\d+" },
new[] { "Web.Controllers.Reports" });
; should be switched since second route ReportsWithMISCode is more specific, means having more parameters.
So it should be:
routes.MapRoute("ReportsWithMISCode",
"Reports/{Action}/{programObjectiveId}/{userName}/{MISCode}",
new { controller = "Reports", action = "Index" },
new { programObjectiveId = @"\d+" },
new[] { "Web.Controllers.Reports" });
routes.MapRoute("ReportsWithoutMISCode",
"Reports/{Action}/{programObjectiveId}/{userName}",
new { controller = "Reports", action = "Index" },
new { programObjectiveId = @"\d+" },
new[] { "Web.Controllers.Reports" });
It is interesting to note that in first case route works in awkward way. It gets matched but third parameter MISCode is appended as query param with question mark like this:
...ReportXXX/101/pt2?MISCode=MyMISCode
After switching to second solution we get friendly url.
Aug 20, 2015
Aug 19, 2015
Regex - Match only first occurence
In UTF-8 HTML text like this :
First,
Second
To achieve this use non greedy expression ?. Basically after you state what is pattern and how often it occurs by using ? you want to limit search only to first occurence.
Example regex with UTF8 greedy expression:
<table>; you want to parse out list of two rows.
<tr class="dummy">
First
</tr>
<tr class="foo">
Second
</tr>
</table>
First,
Second
To achieve this use non greedy expression ?. Basically after you state what is pattern and how often it occurs by using ? you want to limit search only to first occurence.
Example regex with UTF8 greedy expression:
(?<=tr\sclass="\w+">)+?(?>\P{M}\p{M}*)+?(?:\<\/tr\>)+?http://stackoverflow.com/questions/2503413/regular-expression-to-stop-at-first-match
Aug 13, 2015
Aug 11, 2015
Subscribe to:
Posts (Atom)