Friday, January 30, 2015

LINQ to object with data tables

http://www.vbforums.com/showthread.php?628877-RESOLVED-Select-distinct-values-from-a-DataTable

The key is to cast the table to an IEnumerable

Wednesday, January 28, 2015

Debug java scrip in Visual studio

The best way is to use the developer tools in your browser so hit F12 and then go to the script section
Click on start debugging

https://msdn.microsoft.com/en-us/library/dn457346.aspx#BKMK_JavaScript_Just_My_Code

Visual studio show todo

http://www.dotnetperls.com/todo

 View menu > Task List

web services

http://www.kenneth-truyers.net/2012/02/18/ajax-with-jquery-and-web-services/

Find project dot net framework version

http://stackoverflow.com/questions/3231632/how-to-find-the-net-framework-version-of-a-visual-studio-project


  • VB
Project Properties -> Compiler Tab -> Advanced Compile Options button
  • C#
Project Properties -> Application Tab

user id

Dim userId As String = Threading.Thread.CurrentPrincipal.Identity.Name.ToLower

SQL group by

When grouping, keep in mind that all columns that appear in your SELECT column list, that are not aggregated (used along with one of the SQL aggregate functions), have to appear in the GROUP BY clause too.

Tuesday, January 27, 2015

ASP.NET web.config SQL connection string for local

Install SQL express on local, then change connection string below, so when you register a user. it is same.

You can import from Azure sql db to local sql server (after you migrate the localdb to Azure SQL server) 


<connectionStrings>
   <add name="DefaultConnection" connectionString="Data Source=(local);Initial Catalog=RegMSW_db;Persist Security Info=True;User ID=xx;Password=xxxxx" providerName="System.Data.SqlClient" />

 </connectionStrings>

Debugg Javascript in Visual Studio 2010

http://www.codeproject.com/Articles/18921/Using-Visual-Studio-to-Debug-JavaScript-in-IE

Monday, January 26, 2015

vb.net copy interface to another

Public Class X
     Implement I...

press enter will copy all structure over

Sunday, January 25, 2015

SQL express 2014 install errors

https://dyball.wordpress.com/2014/04/05/error-installing-sql-express-2012-or-error-installing-sql-express-2014/

just need to change the install service to Network Service


Saturday, January 17, 2015

OWASP Top 10 course on Pluralsight

really looks like and particularly see what it looks like to break that cryptographic storage, go and take a look at module 7 in the OWASP Top 10 course on Insecure Cryptographic Storage. There's a real risk of developing a false 

simplemembership

new is dot net identity
http://blogs.msdn.com/b/webdev/archive/2013/06/27/introducing-asp-net-identity-membership-system-for-asp-net-applications.aspx

below is out of date
http://weblogs.asp.net/jongalloway//simplemembership-membership-providers-universal-providers-and-the-new-asp-net-4-5-web-forms-and-asp-net-mvc-4-templates

webconfig















Use chrome and F12 to see cookies






use code below to prove different browser has different sessions.


change cookie name so default would not show what under line framework.



<sessionState cookieName="My_SessionId" /> to the <system.web> section of the app's web.config and it changed the cookie name to "My_SessionId".          


























You do not want them to be false









change timeout to small#, 2880 is two days















Friday, January 16, 2015

ASP.NET Application and Page Life Cycle

http://www.codeproject.com/Articles/73728/ASP-NET-Application-and-Page-Life-Cycle

ASP.net sessions

http://asp.net-tutorials.com/state/sessions/

referencesource.microsoft.com

how asp net works

http://www.west-wind.com/presentations/howaspnetworks/howaspnetworks.asp

How to find the .net framework version of a Visual Studio Project?

http://stackoverflow.com/questions/3231632/how-to-find-the-net-framework-version-of-a-visual-studio-project VB Project Properties -> Compiler Tab -> Advanced Compile Options button C# Project Properties -> Application Tab

ODBC admin tool

http://support.microsoft.com/kb/942976 A 64-bit version of the Microsoft Windows operating system includes the following versions of the Microsoft Open Database Connectivity (ODBC) Data Source Administrator tool (Odbcad32.exe): The 32-bit version of the Odbcad32.exe file is located in the %systemdrive%\Windows\SysWoW64 folder. The 64-bit version of the Odbcad32.exe file is located in the %systemdrive%\Windows\System32 folder. The Odbcad32.exe file displays the following types of data source names (DSNs): System DSNs User DSNs

Android course

https://www.coursera.org/specialization/mobilecloudcomputing2/36?utm_medium=courseDescripTop

Tuesday, January 13, 2015

Profile provider

http://www.codeproject.com/Articles/667595/Profile-Provider-in-Asp-Net-MVC

Saturday, January 10, 2015

An unexpected error has occurred. Could not load file or assembly 'WebGrease, Version=1.5.1.25624, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

http://www.coderexception.com/CNBBB3z3PXiPUxxW/could-not-load-file-or-assembly-webgrease-version15125624 Install-Package Microsoft.AspNet.Web.Optimization Update-Package WebGrease Uninstall-Package Microsoft.AspNet.Web.Optimization Uninstall-Package WebGrease Install-Package Microsoft.AspNet.Web.Optimization Update-Package WebGrease

Thursday, January 8, 2015

ASP.NET MVC area

http://www.codeproject.com/Articles/714356/Areas-in-ASP-NET-MVC

Tuesday, January 6, 2015

Lock statement vs Monitor.Enter method

http://stackoverflow.com/questions/2837070/lock-statement-vs-monitor-enter-method

Saturday, January 3, 2015

Friday, January 2, 2015

Thursday, January 1, 2015

Mongo DB: forcing removal of the admin user

http://www.terminalinflection.com/mongo-db-force-admin-removal/

There are many occasions where you get locked out of a Mongo DB database. It could be that the admin password is unknown, or that the only admin user that exists is “read-only” (something that Mongo permits you to do). Fortunately, it’s fairly straightforward to remove the admin database safely and recreate the admin user.
Mongo DB has an idiomatic, not to mention pragmatic approach to user authorization. Access to the database is simplified, and not particular granular, with the idea that access control should be passed more to the connecting application itself. Thus, the default access control is to have no users at all. You need to create an “admin” user account if you want one. Nothing, however enforces this.
One creates an admin user by creating a user on the “admin” database, after logging in to Mongo:
  # mongo localhost
MongoDB shell version: 2.0.2
connecting to: localhost/test
  > use admin
switched to db admin
  >  db.addUser("admin","Password")
And that’s it.
Once this user exists, then every time you login to the database, you need to authenticate, like this:
  # mongo localhost
MongoDB shell version: 2.0.2
connecting to: localhost/test
  > use admin
switched to db admin
  mongo> db.auth("admin","Password")
Failure to authenticate will allow you your connection, but no access to any data. Once again, it’s the fact of the existence of the admin user which enforces access control, as well as the following option in the Mongo DB config file:
  auth=true

Solution

This solution will focus on removal of the admin user in a replica set, because it’s slightly more complicated, and slightly more interesting. If you’re just running a single node, the procedure is considerably easier. Just ignore the cluster steps.
Stop all Mongo processes running in the replica set. These will probably be running with the command line or config file option of “replSet”. Check by running “ps” or checking the /etc/mongod.conf file.
When no Mongo replicas are running, perform the following procedure on each node in turn. You’ll need to bring the Mongo process up at one point, but it is vital that only one replica is running at any one time, otherwise the configuration will get resynchronised from another node, and you don’t want that. You want it changed.

On each node

Change to the mongo directory where the data files reside, possibly /var/lib/mongo but specified in the configuration file by the dbPath parameter.
  # cd /var/lib/mongo
Move the admin.* files somewhere else to back them up.
  # mv admin.* /tmp
It’s that simple. Deleting these datafiles will have removed the admin credentials from the database.
Start the mongo replica daemon on this single node. Depending on your distribution and how it’s configured, it’s probably something like this:
  # /etc/init.d/mongod start
  # mongo localhost
MongoDB shell version: 2.0.2
connecting to: localhost/test
  > use admin
switched to db admin
  > db.addUser("admin","password")
At this point, the admin datafiles should have been recreated. Check that the credentials work:
  > db.auth("admin","password")
1
If this returns the numeral “1”, then the login is successful. However, if this is a cluster, the node you’re on may have been marked as stale. To check and fix:
  > db.system.users.find()
error: { "$err" : "not master and slaveok=false", "code" : 13435 }
  > rs.slaveOk()
not master and slaveok=false
The rs.slaveOk() command will allow you to query normally from the secondary:
  SECONDARY> db.system.users.find()
{ "_id" : ObjectId("4fc4972525a7b704e9a3a09e"), "user" : "admin", "readOnly" : false, "pwd" : "2f1bffb1d28a2cca21679103652b1040" }
Now stop mongo, and repeat the above procedure on the other nodes:
  # /etc/init.d/mongod stop
When you have updated the admin password on all mongod replicas, restart all nodes in the replica set.
Now, you should find that all nodes have admin user accounts, and that you can use these to authenticate against each one.