Monday, September 26, 2016

SSL thumbprint with non ANSI characters

Problem:

I was trying to capture the thumbprint from an SSL certificate on an IIS server.  I opened up the properties view and hit the details tab.  They were nice enough to provide a button to copy the thumbprint to the clipboard.  What they neglect to tell you is that it may include some extra characters.  This is no problem until you park it into a config file for use.  Once you try to match that thumbprint against the visible pattern it will never match due to these non-printable characters.


Solution:

Here is the work around:


Step 1:
Copy and paste the thumbprint from clipboard into notepad.exe. 


Step 2:
Select save for the file but do not save just yet!





Step 3:
Change the encoding type to ANSI vice the default UTF-8



Step 4:
Now during the save you will be prompted with the following message:





Step 5:
Select OK and proceed.  This lets you know that the hidden character was present


Step 6:
Completely close notepad. 


Step 7:
Now open up the file with notepad again.  What you will see is the offending characters displayed.
Remove these and then you will have the full thumbprint for the SSL certificate




Thursday, September 22, 2016

.Net temp folder location on development box

Problem:



I was trying to locate the asp.net temp during a local build session.  I know that the CLR compiles and binds its code in the c:\windows\microsoft.net\framework\... temp area.  But during a local session on a dev box it is built somewhere else.


Solution:



It is in c:\Users\UserName\AppData\Local\Temp\Temporary ASP.NET Files\root\



Thursday, September 15, 2016

Cannot resolve the collation conflict between "Latin1_General_BIN" and "SQL_Latin1_General_CP1_CI_AS" in the equal to operation.

Problem:
I was trying to migrate data from one catalog to the other and hit this error. 


insert claim

select

*

from [MANNHEIM].dbo.CLAIM c

Inner Join Exercise e

on e.Exercise_ID = c.EXERCISE_ID

where e.EXERCISE_ID is not null


The problem was that the field in the source table had a different default format then
the target field.  The way around was to force the query to use a common default collation.




Solution:


insert claim
select
from [MANNHEIM].dbo.CLAIM c
Inner Join Exercise e
on e.Exercise_ID COLLATE DATABASE_DEFAULT = c.EXERCISE_ID COLLATE DATABASE_DEFAULT
where e.EXERCISE_ID is not null


Source:
http://blog.sqlauthority.com/2007/06/11/sql-server-cannot-resolve-collation-conflict-for-equal-to-operation/

Friday, September 9, 2016

SQL Server count rows in a database

Problem:

I began analyzing a legacy database and need to get some statistics on what is being used.
I needed to get a feel for which tables were actually being used.

Solution:

select
schema_name(obj.schema_id) + '.' + obj.name AS [TableName],
row_count
from (
    select
        object_id,
        row_count = sum(row_count)
    from sys.dm_db_partition_stats
    where index_id < 2  -- heap or clustered index
    group by object_id
) Q
join sys.tables obj on obj.object_id = Q.object_id
where row_count > 0
order by [TableName]


Source:

http://stackoverflow.com/questions/428458/counting-rows-for-all-tables-at-once

Wednesday, August 31, 2016

MVC multiple layouts

Issue:

Working an MVC project which required us to use different layouts.  I knew you could do it but was not sure of the syntax. 

Solution:

It turns out there are at least 4 ways to do this.  I only am mentioning the solution we used since it is what we needed.  Feel free to the Net Stuff blog for more details.

Set Layout by Returning from ActionResult

You can override the default layout rendering by returning the layout from the ActionResult. So, this is also a way to render different Layout in your ASP.NET MVC application.




public ActionResult Index()
{
 SampleModel model = new SampleModel();
 //Any Logic
 return View("Index", "_WebmasterLayout", model);
}


Source:

http://www.dotnet-stuff.com/tutorials/aspnet-mvc/how-to-render-different-layout-in-asp-net-mvc

Wednesday, July 20, 2016

0x800a1391 - JavaScript runtime error: '$' is undefined

Problem:

I had decided to upgrade to a newer version of bootstrap datepicker.  I had a new MVC project which started giving me this strange jquery error.


Solution:

The problem I ran into when getting this error was due to the fact that the following statements were not in the <head> of the document, but just before the </body> tag at the end of the document.
@Scripts.Render("~/bundles/jquery")
@Scripts.Render("~/bundles/jqueryui")
@Scripts.Render("~/bundles/bootstrap")
Once I moved them to the <head> of my .cshtml file, everything worked fine.


Source:

http://stackoverflow.com/questions/17672643/0x800a1391-javascript-runtime-error-jquery-is-undefined-mvc-4