SignalR – Real-time web communication between Client and Server Easy c# [Part 1 of 2]

What is SignalR ? ASP.NET SignalR is a new library for ASP.NET developers that makes developing real-time web functionality easy. SignalR allows bi-directional communication between server and client. Servers can now push content to connected clients instantly as it becomes available. SignalR supports Web Sockets, and falls back to other compatible techniques for older browsers. SignalR includes APIs for connection management (for instance, connect and disconnect events), grouping connections, and authorization. Features of this exercise after you complete: # Send real time message to client without client refreshing the page # Receive real time communication or message from client without refreshing the page. #Send message to all connected clients. # Send message to specific client. # Send message to all client except one who sent it… # This is a proof of concept …. you can extend it to the way you want…   How to Install SignalR to MVC C# ? Steps : Open Visual Studio 2015 Create New MVC Project Install SignalR from Nuget Package  – Install-Package Microsoft.AspNet.SignalR -Version 2.2.2 Create SignalR Hub Create Owin Startup File Create A view and include SignalR library reference Test the Application Extend the functionality to the ActionMethod       Testing the […]

» Read more

Installing 64 Bit Oracle Client : Windows 10 – 64 Bit

Scenario : You want to install Oracle Client and ODBC driver in Windows 10 – 64 Bit Files Required : Oracle Instant Client Basic : http://download.oracle.com/otn/nt/instantclient/122010/instantclient-basic-windows.x64-12.2.0.1.0.zip Instant Client Package – ODBC : http://download.oracle.com/otn/nt/instantclient/122010/instantclient-odbc-windows.x64-12.2.0.1.0.zip Step 1 : Download Above 2 Packages. Step 2: Copy all the contents to a single folder and name the folder as “oracle” Step 3: Now copy the folder to c:\ So now the content of c drive should like below Step 4: Now create a folder called tns inside c:\oracle => this folder will be used to save tnsnames.ora file Step 5 : Add TNS_ADMIN variable in Environment Variables TNS_ADMIN  => c:\oracle\tns\ Step 6: Add c:\oracle to the path variable Step 7 : Right click the file c:\oracle\ Step 8 : Now create a sample tns file and save in c:\oracle\tns\ PROD= (DESCRIPTION= (ADDRESS= (PROTOCOL=TCP) (HOST=xxx.oracle.haneefputtur.com (PORT=1521) ) (CONNECT_DATA= (SERVER=dedicated) (SERVICE_NAME=xxx.haneefputtur.com ) ) …. Now your oracle client and odbc driver is ready to use. Step 9 : Create ODBC DSN as follows   Note For 32 Bit Clients Link  for 32 bit Instant Client : http://download.oracle.com/otn/nt/instantclient/122010/instantclient-basic-nt-12.2.0.1.0.zip Link for 32 Bit ODBC Driver : http://download.oracle.com/otn/nt/instantclient/122010/instantclient-odbc-nt-12.2.0.1.0.zip  

» Read more

Error Could not load file or assembly ‘System.Net. ASP.NET MVC C#

Error : Could not load file or assembly ‘System.Net.Http.Formatting, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35’ or one of its dependencies. The system cannot find the file specified. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.IO.FileNotFoundException: Could not load file or assembly ‘System.Net.Http.Formatting, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35’ or one of its dependencies. The system cannot find the file specified. Solution : To resolve this issue before you publish the file make sure you select Copy Local to True from False If the dll property of the file — copy local is  false means the file will not be copied to bin folder while publishing. Set it to true so that file will be copied to bin folder Screenshot before error:   Solution     This will copy the dlls while publishing to Bin folder      

» Read more

Rotativa :: HTTP Error 401.2 – Unauthorized You are not authorized to view this page

Scenario Using Rotativa as PDF convertor in ASP.NET MVC C# with Active directory login authentication Problem HTTP Error 401.2 – Unauthorized You are not authorized to view this page due to invalid authentication headers Cause : If you use Rotativa.ActionAsPDF it will not pass the header values related to authentication to the new page. So option is to use Rotativa.PartialViewAsPdf Sample Code:   public ActionResult ConvertToPDF(string stdId, string vid) { TestModel model = dbfunctions.GetTestValue(stdId, vid); // send model as partial View Pdf not return new Rotativa.PartialViewAsPdf(“TestPDF”, model); } public ActionResult TestPDF(TestModel model) // model with values { // PartialView(pdf) not View(pdf); return PartialView(model); }          

» Read more

Error installing NuGET Packages Visual Studio 2013 – already has a dependency defined for xxxx

When you install new nuget packages you receive error as below.     In order to resolve this follow this steps.   Close Visual Studio Download Latest version of NuGet Package Manage and Install https://marketplace.visualstudio.com/items?itemName=NuGetTeam.NuGetPackageManagerforVisualStudio2013 Step 3: After installation open the Visual Studio and try to install NuGet Package!!!    

» Read more

Install Oracle DB Express and Connect to ASP.Net MVC C# Using Dapper and ODP.net

Tools Used : Oracle DB Express Toad for Oracle ( To explore database– You can also user Oracle Developer)  Visual Studio .net 2013 This tutorial covers following points. Install Oracle DB Express.  ==< Link http://www.oracle.com/technetwork/database/database-technologies/express-edition/downloads/index.html Create a user  — Refer my post => Create user and Schema Create a Schema — Refer my post => Create user and Schema Create a Table ALTER TABLE HPUTTUR.EMPLOYEE DROP PRIMARY KEY CASCADE; DROP TABLE HPUTTUR.EMPLOYEE CASCADE CONSTRAINTS; CREATE TABLE HPUTTUR.EMPLOYEE ( EMPLOYEE_ID NUMBER NOT NULL, EMPLOYEE_NAME VARCHAR2(200 CHAR) NOT NULL, EMPLOYEE_MOBILE VARCHAR2(50 BYTE) NOT NULL, EMPLOYEE_DEPARTMENT VARCHAR2(50 BYTE) NOT NULL ) TABLESPACE SYSTEM RESULT_CACHE (MODE DEFAULT) LOGGING NOCOMPRESS NOCACHE NOPARALLEL MONITORING; CREATE UNIQUE INDEX HPUTTUR.EMPLOYEE_PK ON HPUTTUR.EMPLOYEE (EMPLOYEE_ID) LOGGING TABLESPACE SYSTEM NOPARALLEL;  CREATE OR REPLACE TRIGGER HPUTTUR.EMPLOYEE_TRG BEFORE INSERT ON HPUTTUR.EMPLOYEE REFERENCING NEW AS New OLD AS Old FOR EACH ROW BEGIN — For Toad: Highlight column EMPLOYEE_ID :new.EMPLOYEE_ID := EMPLOYEE_SEQ.NEXTVAL; END EMPLOYEE_TRG; / ALTER TABLE HPUTTUR.EMPLOYEE ADD ( CONSTRAINT EMPLOYEE_PK PRIMARY KEY (EMPLOYEE_ID) USING INDEX HPUTTUR.EMPLOYEE_PK ENABLE VALIDATE); Insert into HPUTTUR.EMPLOYEE (EMPLOYEE_ID, EMPLOYEE_NAME, EMPLOYEE_MOBILE, EMPLOYEE_DEPARTMENT) Values (1, ‘Haneef Puttur’, ‘354354354345’, ‘Computer’); Insert into HPUTTUR.EMPLOYEE (EMPLOYEE_ID, EMPLOYEE_NAME, EMPLOYEE_MOBILE, EMPLOYEE_DEPARTMENT) Values (2, ‘Minnu’, ‘y676756565’, ‘Computer’); Insert into HPUTTUR.EMPLOYEE (EMPLOYEE_ID, EMPLOYEE_NAME, EMPLOYEE_MOBILE, EMPLOYEE_DEPARTMENT) Values (3, ‘Minaal Haneef’, […]

» Read more

Step by Step Instruction – Integrate TinyMCE with Uploadify using ASP.Net MVC C#

Earlier I was posted an article on Integrating Summernote on MVC ASP.Net . I received couple of feedback’s where users were facing issue with large content as the entire data including image will be send to the database and there will be with size of images. As we aware that there is TinyMCE editor which lacks in the area of Image Uploading. Image upload is not realistic in TinyMCE, however apart from that it has all the rich text editing features.  On the other hand Uploadify is a really simple file uploading jquery plugin which helps us in on the fly uploading of the files.   In this project I have merged the functionality of the above two and integrated with MVC ASP.NET C# for easy implementation in any of the project. Features: Rich Text Editing Features of TinyMCE ( You can enhance the features referring to this documentation ) Easy Image upload feature with restriction on file extension as well on file sizes. Seamlessly integrated Uploadify with TinyMCE , even works well with Multiple Files. Uploaded images are stored in the server and only reference is added to text editor hence making the content data small as possible. Complete […]

» Read more

WYSIWYG For Bootstrap ASP.Net MVC with Image Upload Feature

One of the common issue face is adding rich text editor with image upload option in bootstrap project which uses MVC , C# ASP.net I have spent a lot of time to customize TinyMCE editor, however I could not succeed completely. I have found summernote a very lite weight editor for Bootstrap. Step 1 : Create a default MVC ASP.NET project in Visual Studio 2013 Step 2 : Download summernote from http://summernote.org/ Step 3 : Copy the downloaded folder content to Scripts folder as shown Step 4 : Edit View –> Shared -> Layout.cshtml Move jquery bundle to top of the page Step 5: Create a Model , name as News.cs   using System.Web.Mvc; namespace WYSWYG.Models { public class News { public string Title { get; set; } [AllowHtml] public string Content { get; set; } } } Step6 Create a Controller NewsController.cs using System.Web.Mvc; using WYSWYG.Models; namespace WYSWYG.Controllers { public class NewsController : Controller { public ActionResult Index() { News newscontent = new News(); return View(); } [HttpPost] public ActionResult Index(News model) { return View(“NewsDisplay”, model); } } } Step 7 : Create a View and Name it as Index.cshtml under The View Folder News @model WYSWYG.Models.News @{ ViewBag.Title = […]

» Read more

Multi Language Site Creation Using MVC C# , ASP.NET Using Visual Studio 2013 – Kannada / Arabic / English

Scenario : You want to create an web application which supports multi language. Your site may contain models , form labels, hyper links which needs to be in the required language. We can also have a language switcher. Solution : Use Resource .resx xml file. Tools Required : Visual Studio 2013 Features: Extend as many number of Languages you want Form can be created with different language labels Link labels can be changed language switch option Easily editable Resource Files Create New Project Select Web ==> Asp.net MVC4 Web Application ==> Project Name :: Haneef Select Internet Application Right Click Project Name ==> Add New Folder ==> Name it as Resources Right Click Resources Folder which we created ==> Add New Item Select General Tab from left Hand Side  and Select Resources File from Right Side Name the new file as  LangText.Resx Now Enter the string Name and Value as shown below, Click Access Modifier as Public, Then Click Save All as shown Now Right Click LangText.Resx ==> Copy Paste to Same Folder Now Rename the Pasted File as LangText.Ar.Resx Now Edit the Content of Resx file to include Arabic Translations and Save. Now Again make a copy for Kannada […]

» Read more

AJAX Query to fill Select List MVC , C# asp.net

This is Proof of Concept for Querying data using AJAX and filling the drop down list from a oracle database using DB procedures. Model : public class listmodel     {         public string txtdesc{ get; set; }         public string txtval { get; set; } } Controller public JsonResult get_crn_term(string term)         {             var crnlist = functions.getCRN(term) as List<listmodel>;             return Json(crnlist, JsonRequestBehavior.AllowGet);         } Function to Call the Oracle procedure which has the data:   public static List<listmodel> getCRN(string term_code)         {             var p = new OracleDynamicParameters();             p.Add(“p_term”, term_code);             p.Add(“p_crn”, dbType: OracleDbType.RefCursor, direction: ParameterDirection.Output);             var crnlist = new List<listmodel>();             using (SqlMapper.GridReader gr = DB.GetMultiGrid(“procedure.p_get_term_crn”, p))             {                 crnlist = gr.Read<listmodel>().ToList<listmodel>();             }             return crnlist;         } AJAX Script in View   < script > function get_crn_data(data) {         $.ajax({             type: “POST”,             url: “get_crn_term”,             dataType: “json”,             data: “{ term: ‘” + data.value+ “‘}”,             contentType: “application/json; charset=utf-8”,             success: function (data) {                 $(“.crn”).empty();                 var optionhtml1 = ‘<option value=”‘ +                  0 + ‘”>’ + “–Select State–” + ‘</option>’;                 $(“.crn”).append(optionhtml1);                 $.each(data, function (i) {                     var optionhtml = ‘<option value=”‘ +                 data[i].txtval+ ‘”>’ +data[i].txtdesc+ ‘</option>’;                     $(“.crn”).append(optionhtml);                 }); […]

» Read more
1 2