How To Handle Ajax Requests When User Is Not Authenticated

Apr 5, 2010

How do you handle ajax requests when user is not authenticated?

Someone enters the page, leaves room for an hour, returns, adds comment on the page that goes throuh ajax using jQuery ($.post). Since he is not authenticated, method return RedirectToRoute result (redirects to login page). What do you do with it? How do you handle it on client side and how do you handle it in controller?

View 4 Replies

Similar Messages:

VS 2012 - How To Handle Ajax Requests In MVC

Jun 24, 2014

This is sort of a continuation of a previous thread: View thread

The requirement I have is to be able to have a popup form that shows detailed data on a facility. This would be available on various pages of the website where the user may want to drill down and see detailed information on a facility. We also want to allow the user to update the data on the facility if so desired. I have the code working to show the popup form and get the html for the popup from a view. Right now I'm setting the values of the input boxes using razor code that accesses the @model object. That's about as far as I've gotten.

Where I'm struggling is:

1. How to tie the data in the inputs back to the view model.
2. How to write the ajax code to write the data back to the server. I tried using a standard form, but that redirects the original page that popped up the form. I want to leave that page alone and just submit the data back to the server and close the popup.

Now my dev lead wants us to use the dojo toolkit for our javascript library. That would be OK if I already knew what I was doing with regard to web development, but I don't - and documentation is just not very good with regard to dojo. I'm still trying to figure out html and mvc, so I thought I'd see if I can get this scheme working with some other javascript library first, and then see about switching it over to dojo.

I've read some about knockout and jquery, but with everything being so new to me it's hard to get all this to gel in my head, and I'm not sure about my design. I've read some about mvc's built in ajax tools, but so far all I'm seeing is stuff related to getting data and displaying it - not about submitting data.

I'd like to be able to send the data back to the server in the same object structure that I extracted it with - something that matches the model. I think this is doable, but I'm not sure - and the 'how' of it is escaping me at this point.

View 20 Replies

MVC :: To Use AsyncController To Allow User Concurrent Ajax Requests?

Jun 10, 2010

In my ASP.NET MVC2 web app I have a page which goes off and gets results from a number of different web service feeds. These return times vary so I want to basically display them as they return after the page loads. I also want my user to be able to kick of requests that can run concurrently with these other requests.

At the minute my page just seems to queue up the requests. The web service calls returning one at a time in the order they are called and then the user can kick of requests.

Is this a case for the asyncController or is there an easier/better way of working this?

View 5 Replies

How Does IIS Handle Large Volume Of Requests

Jul 26, 2010

I have a standard ASMX web service which uses a lock object to process the first request it receives and reject other requests that come in before processing completes. The web service is hosted on a Windows Server 2003 box with a single-core processor. To test whether this works as expected, I wrote a client that spawns 100 threads. Each thread makes an asynchronous POST call to the web server (i.e., HttpWebRequest.BeginGetResponse()). From my own logging, what I'm seeing on IIS is that two threads are spawned. Let's say thread IDs 1 and 7. Thread 1 is assigned a small number of requests. It accepts and processes them, one after another. Thread 7 is assigned a large number of requests. It rejects them. Does anyone have theories on the following: Why are two threads spawned? And not four or a hundred? Why does there seem to be thread discrimination? Thread 1 looks like it has control of the lock object at all times.

View 1 Replies

Can MVC Handle Regular URL Path Requests Too

Mar 3, 2011

ASP.NET MVC newbie question:

I've set up a MVC site, with a few controllers. Now my site also has a lot of content files, which are stored in a network of subfolders within my web site, and I need to be able to access them directly, e.g.


Is there a way to make this a direct pass-through to the content folder, as specified by the path, or do I have to make a Content controller that interprets the rest of the URL and returns the file as some kind of ActionResult? Bear in mind, of course, that there will be lots of different content types, not just JPEGs.

View 4 Replies

Configuration :: Setting IIS 6 To Handle Sub Domain Requests?

Jun 16, 2010

I need to make my IIS6 to handle sub domain request to the main website so that i can handle it by using HTTPHandler

But i don't know what modifications should be done on IIS to accept unlimited subdomain name requests

View 3 Replies

Configuration :: How Does IIS Handle A Large Volume Of Requests

Jul 26, 2010

How Does IIS Handle a Large Volume of Requests

View 2 Replies

How To Handle Every Request To A Folder (including Requests To Subfolders Within)

Jan 27, 2010

I have a folder structure that is odd and I need to find a way to deal with. Example, if you go to, I would like to have a script in the /x folder that grabs all incoming requests, even if the request was to /x/y/filename or /x/y/z/1/2/filename. Is it possible?

View 1 Replies

Web Forms :: Web Parts And Anonymous User And Authenticated User Is Displayed Differently?

Mar 21, 2011

the Web Part for anonymous user and authenticated user is displayed differently. I faced this problem twise. First time when used Silverlight control in the Web Part and second time when used devexpress control in the Web Part. In both cases problem was with displaying for anonymous user. Silverlight control didn't display. Devexpress control lost it's styles. Both controls had properties that pointed to files. Silverlight control property pointed to the XAP file, and Devexpress control property pointed to the CSS file. It seems to me, that for anonymous user the Web Part cannot find this path or doesn't allow to link to other files.

View 1 Replies

User Controls :: Check Whether User Is Valid And Authenticated Without Using Session?

Feb 17, 2014

How to Check whether user is valid and authenticated without using Session in ASP.Net ....

View 1 Replies

Ajax - Load User Control And Handle Post Back?

Feb 10, 2011

I'm working with 3.5 c#

I've seen a good few questions like this around but havnt actually come across any articles with the answer (maybe just been unlucky with my research!).

Basically I'm looking to have say 3 links (or buttons) on a page, which in turn will dynamically load a specific user control into an update panel with AJAX.

Then I would like the usercontrol loaded to be capable of handling postback within the update panel (basically no page refreshes) to do its processing and return output.

Does anyone have any pointers to articles/blogs covering this?

I've seen many but non covered handling postbacks from the user control or handling the postbacks within the update panel.

View 1 Replies

Security :: Getting User Name Of Authenticated User In Session_Start Of Global?

Jan 6, 2011

I am using form authentication in my website. I have a scenario wherein the user is authenticated but the session has timed out. So, i would like to initialize some session variables in Session_Start of Global.asax (First i check if Request.IsAuthenticated=True). For that i required the name of the user who authenticated. On .aspx pages we can get it using Page.User.Identity.Name but how to get it in global.asax page.

View 1 Replies

Security :: Grant Access To Default Page For All Users - Authenticated & Non-Authenticated?

Aug 18, 2010

I've a default.aspx page in my application's root folder. I added a a page in the root of inetpub that redirects requests to the default page. The idea is that the user need only enter the server name to get to the default page. How can I set things up so that all users have access to the default.aspx and that they only have access to the other pages once they've been authenticated?

I am using Windows Integrated Security and the users are being challenged and authenticated properly. I want them to be able to access Default.aspx without any challenges.

(On a side note which may answer this question, when using WIS does the user *allows* have to be challenged? Isn't it possible to pass through their Windows User and ID without the prompt?)

c: inetpubwwwroot
edirect.aspx (set as default document in IIS and simple executes Response.redirect("sites/mercury/default.aspx")
c:documents and settingsall usersdocumentswebsitesmercurydefault.aspx (home page for the site & server)web.config includes


View 2 Replies

User Authenticated Or Not In Other Modules

Mar 2, 2010

protected void Login1_LoggedIn(object sender, EventArgs e)
User.SetUser(Login1.UserName // and what is user ID ?

and how to check in other module if user authenticated or not?

View 1 Replies

C# - Identify Authenticated User In WCF?

May 19, 2010

I have a WCF service that will be using basic authentication and would like to be able identify "who" is trying to use the service. I know that the HttpContext.Current is NULL and in the WCF service, but do not know what the alternative is to get the username.

For the website, I can use:

userName = HttpContext.Current.Request.ServerVariables["LOGON_USER"];

How do I get userName in the WCF Service?

View 2 Replies

Redirecting To Page If User Is Not Authenticated?

Mar 3, 2010

I have created a website which has Secure folder in which i have got a form which only "admin role" users can see. Now that form will appear if login is successful and it works great, if password or username is wrong then again the loginForm will appear which works great too.

Now the problem is if the users which are not in "admin role" enter the user name and password correctly, instead of coming back to the login page and showing them the "Not Authenticated" message, it gives me an error that myWebsite/login.aspx is not found. I think this is because the name for my login page is "AdminLoginPage.aspx" and which is not found and hence it shows me the error. I dont know where to change the login Page name to "AdminLoginPage.aspx"

View 14 Replies

Security :: Want To Pick Up The Authenticated User Name?

Mar 29, 2010

I want to have my code fetch the authenticated user name that is running my code. There's a line or two of code that will accomplish this and I had it but I've misplaced it.

View 7 Replies

Security :: How To Get Information Of The Authenticated User

Oct 8, 2010

I have a web application on IIS that will authenticate using windows authentication (Active Directory). So when they access the application http://iisserver/webappname/ it ask for username pwd and domain. (currently working) How can I get information of the authenticated user in the web app through c#?

View 3 Replies

Want To Retrieve The Authenticated User Info?

Jan 7, 2011

I am trying to integrate my 4.0(non MVC) website with facebook. I want to retrive the authenticated user info.The samples listed in facebooksdk is based on MVC. i tried to implement it in my website, but getting errors. i am struck.If anyone implemented the facebook connect logic and retrieved the user information using facebook-c#-sdk, please help me how to do this.I tried the same using facebooktoolkit, and i am able to retrive the user info. but the toolkit is having issues with .net 4.0.

View 2 Replies

Getting Authenticated User's Username On A Subdomain

Mar 21, 2011

I have Forms authentication setup for an ASP.NET 4.0 application on - we'll call it MainApp. I also have an ASP.NET 4.0 app running on which (let's call it SubApp) doesn't have access to the main app.

Now, SubApp needs to figure out usernames of users who first logged in to the MainApp and then came to SubApp. I thought that it's enough for those two apps to have the same machine keys and for the SubApp to specify in web.config, so it could read the MainApp's authentication cookie and get username from it.

I did a simple test and when I try to hit some page on SubApp it keeps redirecting to - which doesn't even exist not specified in web.config. Apparently my approach doesn't work, though I don't understand why - main domain's cookie should be accessible on a subdomain, right?

This is how I configure authentication in SubApp:

<authentication mode="Forms">
<forms domain=""/>
<allow users="*"/>

View 1 Replies

How To Check User Is Authenticated While Using Forms Authentication

Mar 10, 2011

How to check if user is authenticated while using Forms Authentication ..?

View 2 Replies

WCF / ASMX :: WCF Storing Authenticated User Information?

Jan 15, 2011

I am building a RESTful service using WCF. I basically want to save information about a user when they authenticate to the WCF service. For example I want to save their first name, last name, account number , and password in order to access the information in other requests in the same session. Since this information is sensitive I can not store it in a cookie.

I don't want to use session state because I plan to run this WCF as a Windows Service. Is there something (class, Assembly) I can use that can save user information and retrieve it per request or do I have to create a custom solution that will create an entry in a database every time a client authenticates to the WCF service.

View 5 Replies

Detect If User Is Authenticated With Active Directory?

May 21, 2010

We have a SSO solution with ADFS for logging into our web app, we also have standard setup that uses authentication with our database. I want to setup a solution that allows for both. So now I am trying to figure out, is there any way for ASP.NET to detect if a user is authenticated with Active Directory so I could do this on the fly? If user is logged in through AD, send through ADFS, else, show login screen. I also realize that this may not work if they are setup to use forms based authentication only after the ADFS process is started.

View 1 Replies

Security :: How To Control The Number Of Authenticated User

Dec 16, 2010

I got only one ideas to control with the session. When user log into the master page, I insert the current login user and session ID and active status to the SQL table. if user logout manually or close the browser or session expired, I want to change the inactive status. So I can check how many active user are there and the system can prompt the required info to the user. But now, I can't find the soultion to change the inactive

status in above condition.

That doesn't seem right to me. I m sure I 'm making incorrect assumption about this matter.

View 3 Replies

Context.User.Identity.IsAuthenticated Always Authenticated?

Mar 3, 2011

I am trying to create a httphandler which will intercept a sample pdf file which we have in our website. The httphandler works fine from within my development machine and even my locally published website that if I just try to connect to the test url: [URL] I will get sent to the invalid access page. So pushing it to our IIS6 machine when I try to go to the URL it serves up the PDF document. context.User.Identity.IsAuthenticated is always showing as true. I'm using forms authentication. below is the code I am using as the handler.

public void ProcessRequest(HttpContext context)
if (context.User.Identity.IsAuthenticated)
string SampleURL = context.Request.AppRelativeCurrentExecutionFilePath;
context.Response.Buffer = true;
using (FileStream fs = new FileStream(HttpContext.Current.Server.MapPath(SampleURL),FileMode.Open))
int length = (int)fs.Length;
byte[] buffer;
using (BinaryReader br = new BinaryReader(fs))
buffer = br.ReadBytes(length);
context.Response.Buffer = true;
context.Response.ContentType = "application/pdf";

in web.config I have the following for form authentication:

<authentication mode="Forms">
<forms name="Sample.Web" loginUrl="~/Security/" defaultUrl="~/default.aspx" protection="All" timeout="60" path="/" requireSSL="false" slidingExpiration="true" enableCrossAppRedirects="false" cookieless="UseDeviceProfile" domain="">
<deny users="?"/>

View 3 Replies

Copyrights 2005-15, All rights reserved