Showing posts with label Asp.net MVC. Show all posts
Showing posts with label Asp.net MVC. Show all posts

Monday, March 19, 2018

Microsoft Edge - SSRS URL does not refresh result render as PDF from Asp.net response.redirect

The problem started when I upgraded my operating system to Windows 10. It comes with Microsoft Edge. My Application was working perfect before. It was returning fresh result from SSRS as PDF. I was using following URL in response.redirect

http://servername/Reportserver?/SSRSRPT2RDL/Main&rs:Command=Render&rs:Format=PDF&year=2018&source=Menu

After upgrade, I have started receiving results from cache. I was wondering what happened suddenly. so I started looking at web page Headers - Status Code. It was 304 (Not Modified). Which means it was not refreshing data and returning results from Cache.

To solve the problem, I have added "rs:ClearSession=true" in the URL. This solved my issue.

http://servername/Reportserver?/SSRSRPT2RDL/Main&rs:Command=Render&rs:Format=PDF&rs:ClearSession=true&year=2018&source=Menu

Thanks

Monday, June 23, 2014

Simple example for Asp.net MVC 4 and Entity Framework for Add/Edit/Delete/View/List Customers

Today we will create very simple Asp.net MVC 4 application with entity framework which will give you basic idea about MVC and entity framework. I am going to use “database first” workflow for entity framework.

Let’s start with following steps:

Step 1: Create a new project with .net 4.5 and choose Asp.net MVC 4 Web application and give name “MvcDemo” and click ok.

Step 2: Now choose “Empty” in template selection. View engine will be “Razor” by default and click Ok. This will create project with basic files and folders.

Step 3: Please create database and create “customer” table with following script.

SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[Customer](
 [Id] [int] IDENTITY(1,1) NOT NULL,
 [Name] [nvarchar](50) NULL,
 [City] [nvarchar](50) NULL,
 [State] [nvarchar](50) NULL,
 CONSTRAINT [PK_Customer] PRIMARY KEY CLUSTERED 
(
 [Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, 
IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, 
ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

Step 4: We will create entity model in our project, for this, right click on “Models” folder and add new item as following and give name “MvcModel”.



Step 5: Select “Generate from database” and click next :



Step 6: Choose “connection string”, click “new connection” and give your database connection and name it “MvcDataEntities” and click Next.



Step 7: Choose “Customer” table and click on finish.



Step 8: This will create model :



Step 9: We have model, now we will create controller which will automatically create views for us.

Step 10: Right click on “Controllers” folder and add “HomeController” with Template “MVC controller with read/write actions and views, using Entity Framework." and click Add.



Step 11: This will create “HomeController” and also associated Views like create.cshtml, delete.cshtml, edit.cshtml etc… :



Step 12: Make it start up project and run. Initial screen will look like following:



Step 13: Click on “Create New” and it will give you following error:



Step 14: To solve this, you have to run nuget package with following command :
Install-Package Microsoft.AspNet.Web.Optimization


Step 15: once you run this nuget package, you have to add namespace in web.config like following.
<add namespace="System.Web.Optimization"/> 

Step 16: Now run your project and you can successfully add, edit, delete and view list of cutomers.

the name 'Scripts' does not exists in the current context in Asp.net MVC 4

You will get this error message when you want to build asp.net MVC 4 application with blank solution. To solve this issue, you have to install the following nuget package in your project:
Install-Package Microsoft.AspNet.Web.Optimization
And also in web.config, add following:
<add namespace="System.Web.Optimization"/> 
It will solve your issue.

Wednesday, June 11, 2014

What is Asp.net MVC?

MVC stands for model-view-controller. MVC is a pattern for developing applications that are well architected, testable and easy to maintain. MVC-based applications contain:

  • Models: Classes that represent the data of the application and that use validation logic to enforce business rules for that data.
  • Views: Template files that your application uses to dynamically generate HTML responses.
  • Controllers: Classes that handle incoming browser requests, retrieve model data, and then specify view templates that return a response to the browser.

React-select is very slow on larger list - Found solution - using react-window

 I had more than 4000 items in searchable dropdownlist. I have used react-select but it was very slow. finally I found complete solution to ...