C# - MVC: Filtering/Varying By Http Status Code In OutputCache Attribute

Jul 1, 2010

In the ASP.NET MVC site that I'm writing, I'm building a generic Error Action that is routed to by an HttpModule, following this tutorial. In this Action, I will return a View corresponding to the status code that is applied to the response inside the HttpModule (after doing this, the module transfers the request over to the Action in question).

That's all good, except that I want to implement caching. I don't want to use the OutputCache attribute without filtering/varying, because that would mean that the page would be cached once. I want the page to be cached once for every possible status code.

Is it possible to somehow filter/vary with OutputCacheAttribute's properties, so that each Response.StatusCode is cached separately?

View 1 Replies


Similar Messages:

Can Use .NET MVC OutputCache While Varying View Content Based

Aug 9, 2010

I'm building an ASP.NET MVC 2 site where I'm using the OutputCache parameter heavily. However, I have a concern: using such caching may interfere with authentication.On all of my pages, I display whether the user is logged in or not. Furthermore, in some of my Views, I do filtering based on user role to determine whether or not to display some page content (for example, the Edit link on one of my pages is only shown to users in the roles of Moderator or Administrator)

View 2 Replies

Http Status Code 401 - Customerrors For 401.2

Jan 13, 2010

I successfully implemented role based authorization in ASP.NET. When a person does not have the needed role he gets to see an error page for 401.2 not authorized.

What I would like to accomplish now is to have a custom 401 page in my application and have it redirected there via settings in the web.config. I tried this:

<customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">
<error statusCode="401" redirect="NoAccess.htm" />
</customErrors>

But this does not get caught. Do I have to override it in IIS instead? I hope not as that would make getting things deployed harder.

View 1 Replies

.net - Get Description For HTTP Status Code?

Aug 22, 2010

In ASP.NET you can set the Response.StatusCode to for example 404. Should the status line / description always be set? (to in this case "404 Page Not Found")

How do you get the description if you only have the code (404)? Is this somewhere in the framework or do you manually have to hardcode the descriptions?

View 3 Replies

AJAX :: Web Site Hangs And Gives Http Status Code 413?

Nov 11, 2010

have a web application hosted on Windows Server 2003 SP2 with IIS 6. I use ASP.net Web Forms and ASP.net AJAX.Some times, when clicking on a button to perform an action the web application does bot respond to the user.After debugging i have found that ErrorSys.WebForms.PageRequestManagerServerErrorException: An unknown error occurred while processing the request on the server. The status code returned from the server was: 413

View 3 Replies

Setting Response / Status Generates "HTTP Status String Is Not Valid" Exception?

Jan 9, 2011

I'm writing an HTTP handler in ASP.NET 4.0 and IIS7 and I need to generate a file-not-found condition.

I copied the following code from Mathew McDonald's new book, Pro ASP.Net 4 in C# 2010. (The response variable is an instance of the current HttpResponse.)

response.Status = "File not found";
response.StatusCode = 404;

However, I found that the first line generates the run-time error HTTP status string is not valid.

If, instead of the lines above, I use the following:

response.Status = "404 Not found";

Then everything seems to work fine. In fact, I even see that response.StatusCode is set to 404 automatically.

My problem is that I don't want this to fail on the production server. So I'd feel much better if I could understand the "correct" way to accomplish this. Why did the first approach work for Mathew McDonald but not for me? And is the second approach always going to be reliable?

View 1 Replies

Filtering Repeater Items Based On User Status / Role?

Dec 9, 2010

I have a tricky requirement where I need to categorise documents attached to a product, available for download, based on the status of the user viewing the product. I.e. my site displays a list of products, clicking on one displays a product details page, and this page includes a list a documents related to the product, such as data sheets, user manuals, etc.

I have been asked to group documents into three classes of availability, v.i.z. those available freely to all users, including anonymous; those available to logged on users; and those available to anonymous users that provide contact information before downloading the document, presumably to boost sales leads.

The anonymous and logged on availabilities are quite easy, but the third seems a bit tricky to me. My first question is, is there a way I can filter documents for only logged on users without hooking into ItemDataBound or something, and my second question is, what is recommended for the case where a user must supply contact information to download a document?

In the second question, it has crossed my mind to actually register the user, but without them having to visit the new user registration page, and then I have role based filtering of documents. Currently the new user registration process automatically adds the Member role to all new users. Users I register 'quietly', just so they can download a document, wont be assigned the Member role, distinguishing them from normally logged on members.

View 1 Replies

Infinite Loop With HTTP 401 Status?

Jul 7, 2010

I wrote an ASP.NET page that requires HTTP Basic authorization, which I put in the Page_Load function:

void Page_Load(object sender, EventArgs e)
{
string auth = Request.Headers["Authorization"];
if (string.IsNullOrEmpty(auth))
{
Response.StatusCode = 401;
}
else
{
string[] usernameAndPassword = Encoding.UTF8.GetString(Convert.FromBase64String(auth)).Split(':');
string username = usernameAndPassword[0];
string password = usernameAndPassword[1];
Login(username, password);
}
}

When I try to view the page in a browser (either Firefox or IE), it asks me for the username and password, and then...asks me for the username and password again.

Why does this happen, and how can I fix it?

View 1 Replies

HTTP Status 401: Unauthorized / Getting Error

Oct 7, 2010

I am working on Asp.net 3.5 page where I am displaying SSRS 2008 report in Reportviewer. But I am getting below error.

The request failed with HTTP status 401: Unauthorized.

Exception Details: System.Net.WebException: The request failed with HTTP status 401: Unauthorized.

Below is my code.

[Code]....

View 1 Replies

The Request Failed With HTTP Status 401: Unauthorized

Feb 21, 2011

I have the following error:

"The request failed with HTTP status 401: Unauthorized"

When i try to use an web site (hosted in IIS on Machine1) call a reporting service report using reportviewer (hosted in SQL Server in Machine2)

I already add Networking service permissions to SSRS in Machine2, but the error continues..

View 5 Replies

WCF / ASMX :: Request Failed With HTTP Status 404?

Nov 15, 2010

I'm new Developer in Web Servicei use VS.2005 C# 2.i have 3 Client PC With Webservice Doing some calculation & Server with ASPX pages the server side will call the client LocalHost webService to do some calculation & return Valuethe problem i get error Massege (The request failed with HTTP status 404: Not Found.)

using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
[code]...

View 1 Replies

Web Forms :: Add WebReference - Request Failed With HTTP Status 400

May 4, 2010

I created a web site in ASP.NET 2005 and I am trying to add a web service located on another server. I can call manualy from IE the web service by pasting the URL below. I can type USER ID & PASSWORD and when I click INVOKE I get approval. When I try to add web refence to my web site for using web service I get error "The request failed with HTTP status 400: Bad request: request-line invalid." and I cannot add reference. [URL] What could be the problem?

View 7 Replies

Change HTTP Status 503 To 200 When Serving App_offline.htm For Specific URL?

Feb 22, 2011

The app_offline.htm file that ASP.NET serves returns the http status 503. This is the correct behavior for most situations. However, in the scenario where a specific URL is requested (e.g. [URL]), I'd like to change the returned http status to 200, while still returning http status 503 in all other situations. Is this possible?

The reason why I want to do this is whenever we do scheduled maintenance on our website, we use the app_offline.htm file, but we don't want our uptime monitoring service [URL] to report downtime during our scheduled maintenance.

I assume this would have to be at the IIS level because the app_offline.htm gets served very early on in the request processing cycle.

View 6 Replies

Custom Error Page For 404 Returns 302 For Http Status

Nov 29, 2010

In my asp.net web site I have custom error pages defined as following in my web.config file.

<customErrors mode="On" defaultRedirect="~/defaulterror.htm" >
<error statusCode="404" redirect="~/404.htm" />

When file is not found it correctly display 404.htm page but the issue is when I do Fiddler trace it returns 302 as HTTP status code.This is a big issue for search engine page indexing due to this lot of broken links still have been indexed recently because of this in my web site. how can I prevent returning 302 as HTTP status code for file not found errors and return 404 for file not found errors.I am using asp.net 3.5.

View 3 Replies

Security :: Could Not Add Web Reference From IIS / The Request Failed With HTTP Status 404: Object Not

Jul 26, 2010

I have added a Web Reference in my IIS, I could not add that in my project.

I have tried with add Web reference -->Web services on the local machine-->a link will be displayed. "Ems_WebSecurity" under services. but once it is clicked it has to give the name in "Web services found at this URL"

but it is showing the following error:

There was an error downloading 'http://localhost/EMS_WebSecurity/Ems_WebSecurity.asmx'.
The request failed with HTTP status 404: Object Not Found.
There was an error downloading 'http://localhost/EMS_WebSecurity/Ems_WebSecurity.asmx/$metadata'.
The request failed with HTTP status 404: Object Not

View 7 Replies

Security :: HTTP Status 403: Forbidden Error When Trying To Access Webservice?

Feb 10, 2011

I hace created a webservice, that is on one server and then I created a web application on another server to consume that webservice. My web application uses threading. In my web application, I call the webservice and it returns me the response. Then my thread sleeps for 20 minutes and then it again calls webservice, but when i call the webservice second time , it fails. Here is the error and stack trace:-

Stack Trace:- at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall)
at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)
at TransactionExport.LocalWebService.TransactionExportStaging.GetDays(String projCode) in C:inetpubwwwrootTransactionExportWeb ReferencesLocalWebServiceReference.vb:line 102
at TransactionExport.TransactionExport.LoadDays() in C:inetpubwwwrootTransactionExportExport.vb:line 267

View 4 Replies

WCF / ASMX :: The Request Failed With Http Status 401 Unauthorized. Web Service?

Mar 16, 2011

I am trying to call webservice from my web application. The web application had integrated windows authentication. I've written custome principal class to do authorization. But when I give call to my web service with default credentials it gives me 'the request failed with http status 401 unauthorized.' error.

When I give call to my local webservice it is running fine (It also has integrated windows authentication) But when I add reference of same web service from QA server I am getting this error. Not sure what is happening. I also tried

WS.PreAuthenticate = false;
WS.Credentials = System.Net.CredentialCache.DefaultCredentials;

View 2 Replies

Security :: ReportViewer - The Request Failed With HTTP Status 401: Unauthorized?

Jan 7, 2010

I have created a page with a ReportViewer on it and have connected it to our reporting server. The problem is thou i get that error message: "The request failed with HTTP status 401: Unauthorized. "when i try to view it. It only works when i run the project in debug mode in CS 2008.Also my site is based on Integrated Windows authentication.

View 2 Replies

Configuration :: The Request Failed With HTTP Status 404 - Object Not Found

Jul 28, 2010

I am getting an error as "The request failed with HTTP status 404: Object Not Found." earlier I used to get the output for this source code.

from the last two days i am scraching my head, i could not solve the problem, but i have traced the problem, that is when i tryed to open 'http://localhost' from my explorer i am not gettting the IIS help page.

View 3 Replies

Report Viewer Error: The Request Failed With HTTP Status 401: Unauthorized?

Sep 9, 2010

I have a asp.net c# web application with contains reports in remote processing mode. I am using the report-viewer control to render the reports. When I run the application in debug mode, I'm able to view my reports however when I publish the application to a different server I get this error message:The request failed with HTTP status 401: Unauthorized.

My report server is on a different server than the location of my published web application. I have added new role assignment to my report server and also added to my web.config but the error persists. I think I am missing something in my aspx page for reportviewer.

View 1 Replies

Security :: Digest Authentication In Web Service Error / The Request Failed With HTTP Status 401

Apr 20, 2010

I am connecting to remote server for web service using ASP.NET 3.5 web site. something like, [URL]. Remote server is providing digest authentication to access the web service. I dont have access to modify authentication on the remote server but I have an windows account on that server. If I try to Access service WSDL through programming I get the following error:

The request failed with HTTP status 401: Unauthorized. Same web service if I try to access through browser, [URL], it asks for user name and password. Entered windows account user name and password, still getting error: You are not authorized to view this page, HTTP Error 401.1 - Unauthorized. How to pass the digest authentication credentials to the web service through visual studio or any other programmatic method?

View 1 Replies

Web Forms :: ReportViewer With Different Server Domains/ The Request Failed With HTTP Status 401- Unauthorized

Dec 10, 2010

I created aMicrosoft.Reporting.WinForms.ReportViewer with a window application. It worked fine when I was in net A with domain A. My application is now moved to net B with domain B. However when I login to my computer I still login netA with domain A, userID and password for A. I then use a A/B switch to switch to net B to run my application running ReportViewer (no login directly to B). But when I run ReportViewer I got errors like below.

The request failed with HTTP status 401: Unauthorized.

StackTrace:

[code]....

View 2 Replies

WCF / ASMX :: The Requested Failed With HTTP Status 404:Not Found When Access The Webmethod In Webservices?

Oct 11, 2010

when I access the webservices URL through browser ,I am able to access the URL ,If i use the webmethod in c# code the error message is diplaying like "The Requested Failed with HTTP Status 404:Not found".

View 5 Replies

SQL Reporting :: The Request Failed With HTTP Status 401: Unauthorized.accesing The Server Report In Ssrs2008?

Dec 6, 2010

The request failed with HTTP status 401: Unauthorized.accesing the server report in ssrs2008

View 2 Replies

WCF / ASMX :: Request Failed With HTTP Status 400: Bad Request Accessing Web Service

May 15, 2010

I have a webservice which works 100% fine on my developer machine. Where Web Service is installed on LOCALHOST on my developer machine,Then i went to my servers, I installed webservice on one server and map it with the server where the website is hosted, Then i tried accessing this service using BROWSER from my web server, it worked fine, That means the mapping was done perfect.Then i run my program on web server (website). It worked fine on page1, then on page2, but when i did the same and call same function on page3, It popped me any error of

View 4 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved