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


Top 5 Contributors of the Month
david stephan
Post New Web Links

Simple url rewriting with HttpHandlerFactory = hard times

Posted By:      Posted Date: April 14, 2011    Points: 0   Category :ASP.Net
 

Hi all,

 

in our website there is just one link that needs to be rewritten. The application is working on .NET 2.0. Since it's just one link i want this to be done with httphandlers. So i've added new class implementing IHttpHandlerFactory to App_Code.

 

 

    public class EventRewriter : IHttpHandlerFactory
    {
        public IHttpHandler GetHandler(HttpContext context, string requestType, string url, string pathTranslated)
        {
            context.RewritePath("Event.aspx");
            string path = context.Server.MapPath("Event.aspx");
            return PageParser.GetCompiledPageInstance("Event.aspx", path, context);
        }

        public void ReleaseHandler(IHttpHandler handler)
        {
        }
    }

In other words - the user has ability to define his own virtual path. That path always should be rewritten to the same physical aspx file. Sounds like such a simple task to do. The user might define his path like .../xxx/yyy . I'm silently adding ".prx" extension to the link - therefore i can easily run httphandler for such extension. I've added appropiate markup to web.config so my class was used everytime someone clicks on link with such extension. And it seems to work. Everytime user clicks on link with .prx - the code execution breakpoints inside GetHandler method. The p


View Complete Post


More Related Resource Links

Simple goal but hard to execute it; Javascript or Asp.Net as best solution?

  

Hello all,

I've been struggling with this issue and I am sure there is a solution out there.
Basically I am trying to cache locally all the data that is sent to all TextBox(es) bound to a GridView.
Javascript would be best since that data would not be kept in the ViewState but at this point I am open to Asp.Net solution too.

Scenario:
=========
I have a Timer and a GridView which pulls the data from one SQL table every X seconds.
This table has 2 fields: id (uniqueidentifier) and comments (varchar(max)) and the data changes every rapidly.

On every page refresh the whole GridView content is replaced with whatever data is in the table.
So that gives me a few scenarios I can think of....for instance:

First request:
ID=23FF803F-3AF0-45CA-B536-096A8E410BCD; Comments="Step 1"

Second request:
ID=23FF803F-3AF0-45CA-B536-096A8E410BCD; Comments="Step 2"

Goal: I'd like to keep the previous value so that Comments="Step 1, Step 2" and so on.

Bear in mind that on a subsequent request that same ID might not exist anymore and the cached info for that ID should also be gone.

Another idea would be to have a 3rd control (i.e,Label) which would hold all the previous values. That way, the user could see the latest values in the TextBox but all the cached previous

Creating a Simple Class in C#

  
The second article in the C# Object-Oriented Programming tutorial describes how classes are created in C# and how behaviour, in the form of publicly visible and private, hidden methods can be added. This demonstrates some of the uses of encapsulation

A Simple and Extensible Radio Button Style GridView

  
The GridView is one of the significant controls in ASP.NET 2.0 and later versions. No doubt it reduces a lot of work time. However, customizing the GridView control is not an easy task. For example, it's hard to add a radio button column to the GridView. This article demonstrates the reason why a radio button column cannot act as normal and how to create a simple and extensible radio button GridView.

Silverlight Simple Animation

  
Silverlight has several built in techniques for animating controls. Many of these technologies are particularly useful for creating simple animations meant to decorate a web page with eye catching movement that draws the reader's attention. In this post I will skip over these decorative technologies, and instead show how to create a simple animation using a technique similar to those used in many games.

URL Rewriting

  
If you click on the link you can have look at how the URL rewriting is working. It can be easily understand with screen shot!!!

Thanks,
Sarav

I thought this would be simple... Trying to create a login does an ajax check before submit

  

I have the standard .net login control that is working.  (Still learning .net after 15yrs of classic)

What I want to do is OnButtonClick run a javascript function (to do an ajax call to the db to check if login is valid or not) and if it returns true, then submit the form normally, else don't submit. The piece that I can't figure out, is how to correctly override the default click even to hit my JS routine and then submit the form properly afterwards.

Thanks ahead of time


URL rewriting with webserver in VS.NET2010

  

Hi,

is it possible to have same URL rewriting behaviour in integrated webserver as in "real" IIS7?


Regards



Hard Code Roles on the Pages

  

If i hard coded role=Manager on the specific SiteMap/Folder/Page/etc. I will have problem when the manager need to remove from access a specific page. I need to change the code ont eh page/SiteMap/Folder more move the file into another folder.


What i have in mind is to change the role to taks oriented. such as role=AddStock, Edit Stock, Delete Stock, Print DO, Add Sales, Edit Sales, Deleted Sales..... (but it will be many role for 1 user compare to just 1 as Manager)


Will this cause performance issues later when each user have 60 roles and if i have 20,000 user will it affect the application performance?


Otherwise any other option? to make it flexible.




User messages without hard coding

  

Hi All,

 

How to manage user messages to avoid hardcoding messages accross the web application.

 

Regards,

 

Arun


postbacks and url rewriting

  

Hi all,

I am using Intelligencia url rewriter for my project and have run in a small problem. I have a regular expression like

<rewrite url="~/(.+)/(.+)/(.+).aspx" to="~/Article.aspx?a=$3&amp;s=$2&amp;p=$1"/>

so a page request like

/parent/category/articlename.aspx is interpreted as /Article.aspx?a=articlename&s=category&p=parent.

This above is all fine, but now when I do a postback (a login block), it picks up the url /Article.aspx?a=articlename&s=category&p=parent and interprets as /Article.aspx?a=article&s=category&p=parent.

Now, how can I make sure that on the postback, it still throws back the original url /parent/category/articlename.aspx so that the url is properly interpreted?

Thanks


css and images gone on url rewriting

  

 I have a program which rewrites a url to a form     website.com/Default.aspx/name/articleid

The Program works fine ,but after URL rewriting my css sheet and images are gone . 

I am new to this and I have read that I should map my css and images to root. 

So ,I hav done some change to the path files of css and images but it stilll doesnt work .

Plz help me over this ...... 

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="TBV.aspx.cs" Inherits="TBV" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Article Page</title>
    <link rel="index" href="~/" title="Home" />
    <link rel="Stylesheet" media="screen,projection" type="text/css" href="~/css/main.css" />
    <link rel="stylesheet" media="print" type="text/css" href="~/css/print.css" />
    <link rel="stylesheet"

Extreme ASP.NET: The Life And Times of an ASP.NET MVC Controller

  

Here the author dissects the ASP.NET MVC framework and looks at how controllers work. He then explains how the framework interacts with your controllers and how you can influence those interactions.

Scott Allen

MSDN Magazine May 2009


Security Briefs: Protect Your Site With URL Rewriting

  

Learn the numerous ways in which you can rewrite URLs to defend against common Web vulnerabilities.

Bryan Sullivan

MSDN Magazine March 2009


Easy Async: Build Concurrent Apps From Simple F# Expressions

  

In this article, the author explores how the F# language helps you create asynchronous function libraries that can be called seamlessly from any other .NET-compliant language.

Chance Coble

MSDN Magazine October 2008


Wicked Code: Silverlight Page Turning Made Simple

  

As we'll show, with just a few lines of JavaScript you can build a general-purpose framework for incorporating page turns into Silverlight 1.0 apps.

Jeff Prosise

MSDN Magazine May 2008


Secure Habits: 8 Simple Rules For Developing More Secure Code

  

Never trust data, model threats against your code, and other good advice from a security expert.

Michael Howard

MSDN Magazine November 2006


Mutant Power: Create A Simple Mutation Testing System With The .NET Framework

  

With mutation testing, the system under test is changed to create a faulty version called a mutant. Here James McCaffrey explains how to do this in .NET.

James McCaffrey

MSDN Magazine April 2006


Categories: 
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