.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Page Methods...security?

Posted By:      Posted Date: October 20, 2010    Points: 0   Category :ASP.Net

hey all,

need some help with page methods.

I'm using page methods in my web app, and now in few of those methods I need to check whether the request is ehm....secure?I have url parameters on my page, so each time page methodis called I check if those parameters are present and validate them against a DB, and then do the other stuff.

now...is there a way to implement this mechanic into each page methodI'm using, instead writing code inside each WebMethod ?

so what I have now is

        public static string MyMethod(string value)
//1.checking if parameters passed are valid

//2.if true then performing actions, else just returning error


what I want to do is get rid of 1. inside the method, and have it like a wrapper or something, so I could do the same validation on each page method I want.

thanks for help


View Complete Post

More Related Resource Links

Using jQuery to directly call ASP.NET AJAX page methods

Here I am looking to explain how to call page methods using jQuery. Using jQuery to directly call ASP.NET AJAX page methods

Page Methods and Yahoo UI


Hello people,
I'm constructing an application with Page Methods and YAHOO UI.
I'm Not using Update Panels because Page Methods are faster than Update Panel.

You can post your experiences with this feature of ASP.NET Extensions and vantages of using this type of architecture.

Thanks a lot.

Flávio Malaquias
Asp.Net Senior Developer

Passing values from web page to custom security trimmer in SharePoint 2010

Hi, In SharePoint 2007 we had a custom security trimmer that implemented ISecurityTrimmer interface. We also had a custom webpart used for search. Now, using HttpContext we passed values from the webpart to security trimmer with additional info needed to trim the results. It worked since trimmer was executed in the same w3wp process as webpart. Now in SharePoint 2010, the architecture for ISecurityTrimmer2 has changed, as it's executed in search process (other w3wp) - not the webpart w3wp so it has no access to the HttpContext. Question is: how to pass custom data, in form of the string, to a security trimmer when search is done from custom code in webart?

Methods and New Page

Hi i got a method Called ConstructTable() .Now when i click a button it needs to open a Created  Webform  and do the method i created.How i this possible

public web methods...how to make private? Security question


I understand how to set security for a ASP.NET web page, how to encrypt a Silverlight page, and a WCF application, but my question goes to this:  given a web method, which by definition must be public, how do you keep people from accessing it outside of your client program?

If your program (client) is the only way to access this web method, then there's no problem.  But it is impossible to make a web method private--it won't compile--so how to keep people from using it?  The only thing I can think of is that if you call your web method by an obscure sounding name, it's likely nobody will guess the URL, and if you set your server so it cannot be searched (dir *.*) by the public, it's unlikely anybody will ever guess the name of the web method.  But this is hardly 100% secure.  And what if you call your web method "DoWork", which is the default OperationContract name in Visual Studio?

What am I missing?



//what I have in mind

public interface IService1
        string DoWork();


public string DoWork()
//secret stuff in here
string SecretStuff = "S

Page Level Security


How do I limit what User/Groups can see a page in SharePoint 2007? Within on particular SITE, I want to be able to say, for example, only Users in the X group can see this page.

I see on the Page Setting the "Audience Targeting" option, but that does not restrict anyone outside that group from clicking "All Site Content" then finding and opening the page from under Pages.

Can someone point me in the right direction?

Thanks in advance.

Todd C - MSCTS SQL Server 2005 - Please mark posts as answered where appropriate.

SharePoint 201 VS 2010 WF: PersistenceException: The security validation for this page is invalid


Setup: Visual studio 2010 SharePoint 2010 Workflow with custom infopath task edit form, with file attachment control. If I attach a file to the infopath task edit form, I got the following error message, though the attachment is saved, but the next task is not created and the current task is not marked as completed either.

09/27/2010 15:34:31.18     w3wp.exe (0x2B88)                           0x2844    SharePoint Foundation             Workflow Infrastructure           88xr    Unexpected    WinWF Internal Error, terminating workflow Id# 04621f32-17d4-439a-883a-7566b96481bb     
09/27/2010 15:34:31.18     w3wp.exe (0x2B88)                           0x2844    SharePoint Foundation             Workflow Infrastructure           98d4    Unexpected    System.Workflow.Runtime.Hosting.Pers

Page Methods



In my page I am using page methods to call an webmethod in the server side.If suppose there is an exception in that web method I want to redirect to some other page,but i m not able to do that.

can anyone help me on this?




how to use page methods in content page


hi all,

I wish to create a website based on ajax functionality using Master and Content pages.

I want to use page method or xmlhttprequest object to check  some validations in registration form,which is a content page of my website. Is it possible to work so or is there any other method to do it.
The code I'v written using page method in  normal aspx page working fine but it is not working in contnet page.

 Please let me know the solution..

thanks in advance

Sharepoint 2007 publishing site home page displays unknown file type security message


I am using sharepoint 2007 sp2, it has been workig fine for the past 8 months but since one of the developers installed .net 4.0 framework, every time we create a new sharepoit publishng site or extend and existing application the home url displays an "Unknown File Type" security warning message and asks users to download the file.  If i manually tupe in the full url http://www.mysite.com/pages/default.aspx it is displayed correctly. I have uninstalled .net 4 from the server but i still have the same  error. I have tried to replicate this error on a development server but sharepoitn works fine on that even with .net 4.0 installed.

Has anyone had the same issue ? I would appreciate  any suggestios or help with troubleshootig this issue.


How to call page methods from a Master page ?



I have written web methods in code behind and I'm able to call them using PageMethods.(method name) in an ordinary aspx page.

If I'm trying to call the webmethods in a master page using PageMethods.(method name), it is throwing a jscript error pagemethods

is undefined.

My code is like this:


    public static string[] GetTimes()
        dt1 = DateTime.Now;
        string[] a = { };
        a[0] = dt1.ToUniversalTime().Subtract(new TimeSpan(5, 0, 0)).ToString("HH:mm");
        a[1] = dt1.ToUniversalTime().ToString("HH:mm");
        a[2] = dt1.ToUniversalTime().AddHours(0d).ToString("HH:mm");
        a[3] = dt1.ToUniversalTime().AddHours(8d).ToString("HH:mm");
        return a;

<script language="javascript">

  function UpdateNYCTime() {

      PageMethods.GetTimes(times, OnSucceeded);

 function OnSucceeded(result, userContext, methodName) {
   $get('spanNYC').innerHTML = result[0].toString(); 




Any Suggestions ? If I cannot call page methods from master page page, is there any another way of calling them ?




Page Methods querystrings are null



I'm having problems with accessing querystring params in my page method. Everywhere I read it says you can access querystrings just fine, but when I try it just returns null, what's the problem?

same problem I found -  http://stackoverflow.com/questions/1765188/access-to-querystring-session-from-a-static-method


thanks in advance

Why a Security Warning on web page loading? How can code or users avoid it?


My asp.net page now gives a popup box titled "Security Warning" when the page loads. There are multiple pages in my app that do this. The content of the dialog box reads "Do you want to view only the webpage content that was delivered securely?"

Why is this happening all of a sudden? I think it's because the pages contain some http links to external site pages, but i don't remember seeing the message before, and those "nonsecure" links have been there from the beginning. I did add 30+ images though, sourced from in another directory of the project.

Is there some way i can make the images and links "secure"; delivered via https?

Is there some browser setting for users to set so they don't see this popup every time one of the many pages in this website loads?

All feedback and insight is appreciated!!!

Custom access denied page for role based security


I have implemented role based security in my asp.net 2.0 vb.net application using windows authentication and the windowstokenroleprovider and limiting access to certain pages using the location tag to specific active directory groups.

The issue is that when a user tries to access a page they are not authorized to view it brings up a login prompt and when it does not pass it takes them to the default page that tells them they are not authorized to view the page. I am wondering if there is a way to throw up a custom page that tells them they are not athorized to view the page that I can incorporate into the site itself with the header and so forth? It would be great if this page could come up in lieu of the sign in box popping up as well.


The security validation for this page is invalid


I have SharePoint 2010 installed in a lab and have encountered an error:

"The security validation for this page is invalid. Click Back in your Web browser, refresh the page, and try your operation again."

This occurs when trying to modify a list's view in order to change a default sort order and possibly other properties on that list.  I read that one can disable validation in Central Admin > Web Applications > General Settings, and that although this is not recommended, it did allow me to save modifications to a view.  Unfortunately, switching security validation off causes the Silverlight popups that allow creating new document libraries, pages, etc no longer works.  The error is:

"Error, An unhandled exception occurred in the Silverlight Application"

There are no features, or other custom code running.  This is a plain install of SharePoint 2010.

This seems to be happening on the My Sites site collection.  When I am logged in as the farm admin, I don't receive this error.  But if I am logged in as normal user, who does have site ownership - full control - the error occurs.

My environment is configured like:

http://lab.contoso.com - Top level publishing site

http://lab.contoso.com/members/sites - My Sites (members is a managed

The Decorator Pattern & Extension Methods

The decorator pattern provides a formal way to add new functionality to an existing type, without sub-classing. First question: What is wrong with classical inheritance? In and of itself, nothing is wrong with the good old Is-A relationship. It is very common to derive a new class from an existing base class in order to override a few virtual members, and add a pinch of new functionality.

Changing the graphics on the home page of a SharePoint site

When you create a site in Microsoft Windows SharePoint Services by using the default Team Site template, the home page includes two default graphics. A Windows SharePoint Services graphic appears in the body of the page, and a picture of a house in a circle appears near the site title. You can change these graphics to customize your site. Changing the smaller graphic requires a Windows SharePoint Services compatible Web page editor
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend