Category: HowTo

  • MVC4 and Simple messaging system

      MVC4  Developer preview with mobile support just released. And,because best way to deal with is within an application,I decide to create a simple messaging system for any site that is made with MVC. Description: I begin with a registered user. What he can do: 1. Create messages ( subject + body ) to send…

  • Asp.NET MVC,Jquery and Razor – Cascading dropdown,retrieving partial views,Json send objects,handling errors

    There are many blogs and other posts on using jQuery with MVC. You can find individual posts on: ·         How to send objects to an action method via JavaScript. ·         How to retrieve partial views. ·         How to handle errors. I have written a sample showing how to do all of these together. The sample…

  • MVC Zip Result

    Sometimes you need to send to the user more than 1 file – or,maybe,the file is too large The simplest way is : made a zip file that contains the others. What do you need 1. SharpzipLib from http://www.icsharpcode.net/opensource/sharpziplib/ ( or download via NuGet in VS) 2. obtain the file(s) that you want as a…

  • ASP.NET MVC make users–roles fast

    please left click on “Microsoft SQL Server Management Studio (push button)” please create a database in “Microsoft SQL Server Management Studio” please left click on “C:\Windows\system32\cmd.exe (push button)” and enter the following command : aspnet_regsql.exe -E -S .\SQLExpress -d proprii -A rm please left click on “ListPanel (list)” in “Microsoft SQL Server Management Studio” please…

  • mvc windows authentication

    If you want to use Windows Authentication with MVC : Step 1 : In web.config,put authentication mode windows Step 2 : in IIS disable anonymous Step 3 :  go to Views\Shared\LogOnUserControl.ascx and remove logoff / logon links.

  • Optimizing EF4 and EDMGen2

    Just reading (from Adrian Florea links ) how the EF4 could be optimized : http://www.codeproject.com/KB/database/PerfEntityFramework.aspx First modification is to “Pre-generated Your View”. For this you must have .ssdl,.csdl,and .msl files – so you change the “Metadata Artifact Processing property to: Copy to Output Directory.”. Then you process the .ssdl,.csdl,and .msl with edmgen in order to…

  • Error intercepting in MVC when saving data

    I have seen many times in MVC the following code,when doing a post and saving data : Why is not good ? I will do a simple example : if some error occurs on the database level ( such as simple unique index on a name column ) or even some error occurs whenestablishing the…

  • Five common mistakes for ASP.NET (MVC) accesing resources : css,js,images,ajax

    To have once for all the link to show to people,because too much makes the same error again and again. (From here – you can use ResolveUrl or Url.Content – it’s the same for me. I use ResolveUrl because I used first …) Case 1 The image does not display Please check you have the…

  • Generating history trigger with EF,edmx and TT files

    I have wrote in an older post ( http://msprogrammer.serviciipeweb.ro/2010/06/28/ef-automatic-history-of-table-and-t4-files-tt-files/ ) how to generate history code for tables . The easy solution was to create a tt file that track for the ObjectContext the SaveChanges for each table that has a “history” in name. the limitation is that,when you raise an sql command such as “update…

  • Logparser quick and dirty

    Sometimes you must find information in text files. Many,many text files,like IIS logs or other custom non-regular formats. I have a bot from http://www.imified.com/ – and I log the messages with log4net in text files,with another messages. An entry looks like that : System.ArgumentException: ;channel=private;botkey=<guid>;userkey=<guid>;user=name@yhaoo.com;network=Yahoo;msg=hello;step=1;value0=hello;to=asdasd And there are multiple log files that I want to…