Web server extensions - CHAPTER 5 PERMUTATIONS PATTERN parameter is the

CHAPTER 5 PERMUTATIONS PATTERN parameter is the MIME type to test. The second and third parameters are numeric values returned to the caller that indicate the priority of the MIME type. The priority calculation is based on levels and its associated q values. The levels result from the priority precedence of text/xml to text/*. The q values are associated with the Accept identifier. In the implementation of the method Compare, there are two parameters: x and y. The method implementation has to figure out which value is greater than the other. To get a priority level, the method CalculateValue is called for each parameter. Then the levels (levelx and levely) are compared. If one of the levels is higher, the appropriate integer value is returned. If the levels are equal, the q values (qvaluexand qvaluey) are tested and the appropriate integer value is returned. After the MIME types have been sorted, URLRewriterASPNet will call the rewriter DefaultRewriter to generate the return content, which is step 5. Following is the implementation of DefaultRewriter: public class DefaultRewriter : IRewriter protected HttpApplication _app; private Regex _xml = new Regex(”xml”) private Regex _html = new Regex(”html”) private Regex _text = new Regex(”plain”) public DefaultRewriter(HttpApplication app) _app = app; E B V N private bool DoesFileExistAndRewrite(string filename) { string path = _app.Request.PhysicalPath + filename; FileAttributes attributes; try { attributes = File.GetAttributes(path); } catch (FileNotFoundException ex) { return false; } if ((attributes & FileAttributes.Directory) == 0) { _app.Context.RewritePath(filename); return true; else return false; } } public virtual bool WriteRedirection(string mimetype) { if (_xml.IsMatch(mimetype)) { return DoesFileExistAndRewrite(”default.xhtml”); } if (_html.IsMatch(mimetype)) { return DoesFileExistAndRewrite(”default.html”); }
Visit our web design programs services for an affordable and reliable webhost to suit all your needs.

Leave a Reply