Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I am deploying an application page (globally), I have a button on the editform.aspx. When a user clicks on the button, it redirects to the application page in a new window but I am getting an error Access denied.

Below is my code in the page load function:

           SPSecurity.RunWithElevatedPrivileges(delegate()
            {if (Request.QueryString["IDs"] != null)
                {

                    ticketID= Request.QueryString["IDs"].ToString();

                }
                else
                {
                    ticketID= "";
                }
                    ticketIdTEXTBOX.Text = ticketID;
});

I am getting Access Denied, screen shot below:

enter image description here

share|improve this question
    
If you comment out that section of code, do you still get the access denied message when viewing the page? –  John Chapman Feb 9 '12 at 19:04
    
yes john i still get the access denied –  spStacker Feb 9 '12 at 19:42

3 Answers 3

up vote 4 down vote accepted

Using firebug (or chrome or ie dev tools) check if your redirect button redirects you to correct address. (For example you may expect that it redirects to http://mysite/sites/cars/_layouts/myApplicationPage.aspx, but it actually redirects to http://mysite/_layouts/myApplicationPage.aspx where you get access denied).

And also (this is not an answer, but note), it is absolutely no make sense to use RunWithElevatedPrivileges to access Request.QueryString.

edit
_layouts is a virtual directory in iis, which means that it maps to the physical path (for sharepoint it is 14\template\layout). Every sharepoint web application has this virtual directory, which means that yes, it is accessible between all web applications.

You may have two site collections under http://mysite/ and http://mysite/sites/sitecol. Your application page is accessible using http://mysite/_layouts/myapplicationpage.aspx and http://mysite/sites/sitecol/_layouts/myapplicationpage.aspx. But when user access to this application pages security still working for user, because it requests page in particular site collection. And this means that if user has no sufficient rights under http://mysite/ he gets access denied under http://mysite/_layouts/myapplicationpage.aspx, but can successfully navigate to http://mysite/sites/sitecol/_layouts/myapplicationpage.aspx (again, if user has rights).
Hope I answer your question.

share|improve this answer
    
thanks for the reply, i think that the url might be the issue ...'sitecollname' is the sitecollection i m using for development.... mysite/sites/sitecollname/sitename/Home.aspx ...the link that have given is mysite/_Layouts, i am assuming that the layout folder resides under the webapplication? any suggestions? –  spStacker Feb 9 '12 at 19:41
    
The Layouts folder is a virtual directory that exists beneath each and every Site Collection on each and every web application. –  James Love Feb 9 '12 at 19:59
    
@spStacker, please refer to my update, James Love thanks for follow up –  Kai Feb 9 '12 at 20:20
    
Excellent! it was the url i changed it from "mysite/_layouts/myapplicationpage.aspx,"; TO "mysite/sites/sitecol/_layouts/myapplicationpage.aspx"; ..Thanks a lot guys!..Kai Thanks for detailed explanation! –  spStacker Feb 9 '12 at 20:38
    
You are welcome. If you have subsites under site collection, you should redirect to relative to subsite address (for example http://mysite/sites/sitecollname/sitename/_layouts/myapplicationpage.aspx), because your particular user (again under permissions) may has no access to root site. –  Kai Feb 9 '12 at 21:06

I encountered a similar issue in the past. I was able to get through the problem by using teh Farm Account to deploy the solution. Hopefully this helps you out!

Good Luck!

share|improve this answer

Make sure that all resources the page uses are accessible to the current user. Things to consider include but are not limited to:

  • Master Page checked in and viewable by user
  • CSS files stored in SharePoint are checked in and viewable by user
  • JavaScript files stored in SharePoint are checked in and viewable by user
  • Image files (including favicon) stored in SharePoint are checked in and viewable by user
  • Web Parts and other controls on the page don't utilize resources not accessible by the user
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.