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

Post New Web Links

Access RouteCollection in custom RedirectToRouteResult

Posted By:      Posted Date: September 26, 2010    Points: 0   Category :ASP.Net

I'm making a custom RedirectToRouteResult so I can have it return a JavaScriptResult if it's an ajaxrequest. To be able to generate the url I think I need access to the RouteCollection but how do I access it in there? Obviously the original RedirectToRouteResult is able to generate the url but I don't know how it does it.

public class RedirectToRouteResult : System.Web.Mvc.RedirectToRouteResult
    public RedirectToRouteResult(string route, object routevalues) : base(route, new RouteValueDictionary(routevalues))

    public override void ExecuteResult(ControllerContext context)
        if (context.HttpContext.Request.IsAjaxRequest())
            string url = UrlHelper.GenerateUrl(this.RouteName,

View Complete Post

More Related Resource Links

ADO.NET: Building a Custom Data Provider for Use with the .NET Data Access Framework


The System.Data.dll assembly in the .NET Framework contains namespaces whose base classes can be used to create custom data providers. These namespaces also define a number of data access interfaces and base classes that let developers create data providers that will interoperate with other custom providers. Using the ADO.NET classes Connection, Command, DataReader, and DataAdapter, writing a provider is easier than writing one for OLE DB. This article explains these classes and their implementation, and how they can be used to write a variety of different kinds of data providers.

Bob Beauchemin

MSDN Magazine December 2001

Access Model Validation inside Custom Model Binder.

Hello,Is it possible, inside a Custom Model Binder, to fire "something" that "says" the value is invalid so it gets handled by validation part?Basically, I am getting an exception when the value for the property is invalid.Thank You,Miguel

custom timer job Access denied sharepoint 2010

Hi, I have a question regarding to custom timer job will be happy if you could help us. The problem is that - owstimer.exe running the timer job crashes. - Question why? Launch debugg in the feature - running the timer job is falling on taskJob.Update (); writes SecurityException  I developed the Job TIMER on moss2007 that everything worked, Now we turned from 2007 to sharepoint 2010 and Job TIMER does not work. I tried to note all of the code is inside the function Execute in  job timer might have something to code blocks. But it also did not help. Eventvwr he writes in the following error: The description for Event ID 0 from source Application can not be found. Either the component that raises this event is not installed on your local computer or the installation is corrupted. You can install or repair the component on the local computer. If the event originated on another computer, the display information had to be saved with the event. The following information was included with the event: Custom Timer Jobs: func FeatureActivated Access denied. the message resource is present but the message is not found in the string / message table what the solution to that-timer job that will work? Thank you Moshes

Custom Entity Framework template and access to the database type

First and foremost ... I already made a few changes in the template, the most important one changing the methods generated for stored procedures with OUTPUT parameters and no resultset so that instead of instantiating a few OutputParameter objects, passing them to the method and extracting the values (all without any type checking) you just call the method with a few "out someType?" parameters so I do not need the very basics. I am totally confused by all those GlobalItem, EdmProperty, BuiltInTypeKind, TypeUsage and all this made of objects, all alike and all different though so as soon as I need more data than what's already used by the template I run into problems :-(What I would like is to change the WritePrimitiveTypeProperty() so that it outputs [StringLength(xxx)]  for all char, varchar, nchar and nvarchar properties. But I can't find a way to get from an EdmProperty in the model to the database type in the store.Can anyone help me?In case anyone is interested here's the modified stored procedure mapping code for the template. The first code replaces the original in the .tt: //////// //////// Write EntityContainer and ObjectContext Function Import methods. //////// region.Begin(GetResourceString("Template_RegionFunctionImports")); foreach (EdmFunction edmFunction in container.FunctionIm

How do I access the custom headers created with System.Net.Mail?

I've created some custom headers for my emails.  I've used a breakpoint to see that they are being added to the collection correctly.  I don't understand how to access these from the email that's generated though.  I'm currently dropping the emails into a pickup directory on my local machine and viewing them with Windows Mail.  I have "view all" headers checked in Windows mail but still don't see them when I open my emails in the pick up directory.Can someone please tell me how to access the headers that I added?  Below is an example of how I did it.  I'm hoping to add things like name, address, phone... etc, and then have them visible in the email.   Is this even the correct use of custom headers? message.Headers.Add("X-Name", txtName.Text);  

Custom Web Part doesn't work with in anonymous access

Hi there, I have a custom webpart in a farm solution deployed to my site. Anonymous users should be able to view the site, however they can't because they are required to login due to the custom web part. If i remove the webpart from the page, anonymous users can view the site perfectly without the need to login. There is nothing really special about the webpart. It's a visual web part which uses the site and it's web data to display a sort of menu. Any idea? Thx in advance! Brecht

How can i access to params and args defined in parent activity from custom NativeActivity


There is a scenario that the custom NativeActivity need to access to params or args defined in parent activity. What i have done as below

 protected override void Execute(NativeActivityContext context)


   WorkflowInstanceProxy proxy = context.GetExtension<WorkflowInstanceInfo>().GetProxy();

   Activity root = proxy.WorkflowDefinition;

   Activity rootChild = WorkflowInspectionServices.GetActivities(root).ElementAt(0);

   EditingContext ec = new EditingContext();

   ModelTreeManager mtm = new ModelTreeManager(ec);


   ModelItem modelItem = mtm.Root;

   ModelProperty c1 = modelItem.Properties["Variables"];

   ModelItemCollection c2 = c1.Collection;

   dynamic c3 = c2[0].GetCurrentValue();

   string value = c3.Get(context);


Apparently it is not possible to access to external params with local context so the error prompt "An activity can only access its own implementation variables."

My question is how to get it ? Is there another easy way to do so ?



be together be stro

Custom Navigation control get access denied for visitor


Hi all,

I made a custom control for top navigation which iterate through all site within site collection.

But I get access denied error for user which is not an admin (has read access).

I try to use

            SPSite oSiteCollection = SPContext.Current.Site;

                using (SPSite oSite = new SPSite(oSiteCollection.Url))
                    SPWebCollection collWebsite = oSite.AllWebs;

                    //my code to render the custom control



but no luck.

I found that we can also using SPUserToken, I made it like bel

Access Denied Error Message from Custom Webpart



I am new to MOSS so can anyone please help me to solve this problem.


I've a list in MOSS-2007, and a group of people with Read Only Rights so they cannot change any list item. But I want to give them access to edit one column (i-e Comments) in that list.

So I created a custom web part page and put a comments text box in it. At DispForm.aspx page of list there is a link which redirects to Custom page for adding comments and I am passing Item ID in query string.

But the problem is that when anyone adds the comment on custom page an ACCESS DENIED message appears. I've even set "web.AllowUnsafeUpdates = true" but didn't work


                SPWeb web = SPContext.Current.Web;
                SPList lstTIX = web.Lists["ListName"];


Unable to access custom extended property


When I try to access the .ExtendedProperties["RequestChangeRequired"].ToString() in the onTaskChanged_Invoked method on a workflow I get the error:  "Object Not Set To Instance of an Object".

I have a custom content type on a task list in a custom workflow.  I want to set my Task to either Approved, Major Change or Minor Change.  So i have 3 buttons on the .aspx page for the content type when the users edit the task.  If they click the Minor button the following code is executed:

public void BtnMinor_Click(object sender, EventArgs e)
            Hashtable taskHash = new Hashtable();
            taskHash["RequestReviewerComment"] = RequestReviewerComment.Text;
            taskHash["RequestApproved"] = "false";
            taskHash["RequestChangeRequired"] = "minor";
            taskHash["Approved"] = "false";
            taskHash["Status"] = "complete";
            SPWorkflowTask.AlterTask(m_task, taskHash, true);

            SPUtility.Redirect(List.DefaultViewUrl, SPRedirectFlags.UseSource, HttpContext.Current);

Then in my onTaskChanged_Invoked method the following code is executed but it fals when it tries to access the "RequestChangeRequired

Access denied: security exception in custom timer job




I am getting access denied: security exception when I tried to activate my custom timer job feature in sharepoint 2010. When I deployed thru visual studio, it activates it and works fine but when I deployed the same .wsp thru powershell and tried to activate it I am getting the following error.

The application attempted to perform an operation not allowed by the security policy.  To grant this application the required permission please contact your system administrator or change the application's trust level in the configuration file.

Exception Details: System.Security.SecurityException: Access denied.


Please help me.


Access denied: security exception in custom timer job




I am getting access denied: security exception when I tried to activate my custom timer job feature in sharepoint 2010. When I deployed thru visual studio, it activates it and works fine but when I deployed the same .wsp thru powershell and tried to activate it I am getting the following error.

The application attempted to perform an operation not allowed by the security policy.  To grant this application the required permission please contact your system administrator or change the application's trust level in the configuration file.

Exception Details: System.Security.SecurityException: Access denied.


Please help me.


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.


access denied error in custom login page using custom membership provider/ roleprovider in the FBA u



I have deployed my custommebrship assembly and role provider assembly in the sts web config , central admin web config  and current web appln web config 's. i have created a  dll which has  login control and in the sign_authenticate event i am creating the securitytoken.

when i establish a session using the security token created using the iissettings object, and  while tryibng to redirect to the   home page of the/landing page of the web appln am Getting access denied error. 

signInControl_Authenticate(object sender, AuthenticateEventArgs e)




e.Authenticated = true; //till this line  it worked success.

 base.RedirectToSuccessUrl(); //here it throws  :" Eror: access  denied "     current ly signed in user : myname sign is as   diuff. user


anybody knows how to overcome this , means authentication is  success, but authoriation didnt work.

 how can i get asuccessfull login to theweb appln/ siteccollection? in my role provder class i  have created my own roles

for user name: myname

role name:  Administrators, Contributor.

any help is appreciated





Can you access the WorkflowDesigner from a custom ActivityDesigner?


Is it possible to access the WorkflowDesigner that my current custom activity is contained in ... from within that custom activity's designer? 

I tried walking up the visual tree looking for WorkflowDesigner type, but it never gets there.

How do I Access Variables Between Custom Activities From Code?


Basically, I have custom activity and I have a variable in it that I would like to access in another custom actvity. It it possible to do this without writting the acutal workflow from code and still use the designer? The best way to describe it would be that I want to declare a global variable from within an activity that would be available to any other activity.

This is an example of what I am trying to:

public class activity1 : NativeActivity

    protected override void Execute(NativeActivityContext context)
      string text = "Sent between activities!";

And here is the activity in which I would like to get the contents of the property:

 public class activity2 : NativeActivity
    protected override void Execute(NativeActivityContext context)
      string text = "";
      text = Convert.ToString(context.Properties.Find("globalText"));

Stepping through the code shows that the "context" object has zero properties once I enter the second activity. According to different sources this should be working because the context object should still contain my property correct?

Access report server database connection information from custom security extension



Is there any way from my custom security extension that I can get to and unencrypt the database connection information held within the RSReportServer.config file?



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