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

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

ASP.NET MVC Razor Sample HTML Helper Creation

Simplest example of creating an HTML helper method in Asp.net MVC Razor View In this example I am creating an helper method to format the currency cuurency color to be red if value is minus and green if value is positive. Step 1 : Create the helper function Step 2 : Create an decimal array Step 3. Run a loop to get each value of decimal array and call the helper method to format the view. This is a sample example and can be extended to achieve other goals.   @{ var amounts = new List<Decimal> { 12.34m, 12.45m, -12,-19,32.5m,123, 234, -56 }; } <ul> @foreach (Decimal amount in amounts ) { <li> @FormatAmount(amount)</li> } </ul> @helper FormatAmount(decimal amount) { var color = “green”; if (amount < 0 ) { color = “red”; } <span style=”color:@color”>Pending Amount Is : @String.Format(“{0:c}”, amount) </span> } Output .

» Read more

How to Display Line Numbers in the Editor Visual Studio 2013

Line numbers aren’t added to your code; t hey’re just for reference. If you want line numbers to print, in the Print dialog box, select the Include line numbers check box. To display line numbers in code On the menu bar, choose Tools, Options. Expand the Text Editor node, and then select either the node for the language you are using, or All Languages to turn on line numbers in all languages. Or you can type line number in the Quick Launch box .

» Read more