private string GetActionAttribute() { string virtualPathString; string action = this.Action; if (!string.IsNullOrEmpty(action)) { return(action); } VirtualPath clientFilePath = this.Context.Request.ClientFilePath; if (this.Context.ServerExecuteDepth == 0) { virtualPathString = clientFilePath.VirtualPathString; int num = virtualPathString.LastIndexOf('/'); if (num >= 0) { virtualPathString = virtualPathString.Substring(num + 1); } } else { VirtualPath currentExecutionFilePathObject = this.Context.Request.CurrentExecutionFilePathObject; virtualPathString = clientFilePath.MakeRelative(currentExecutionFilePathObject).VirtualPathString; } if ((CookielessHelperClass.UseCookieless(this.Context, false, FormsAuthentication.CookieMode) && (this.Context.Request != null)) && (this.Context.Response != null)) { virtualPathString = this.Context.Response.ApplyAppPathModifier(virtualPathString); } string clientQueryString = this.Page.ClientQueryString; if (!string.IsNullOrEmpty(clientQueryString)) { virtualPathString = virtualPathString + "?" + clientQueryString; } return(virtualPathString); }
private string GetActionAttribute() { // If the Action property is nonempty, we use it instead of the current page. This allows the developer // to support scenarios like PathInfo, UrlMapping, etc. (DevDiv Bugs 164390) string actionProperty = Action; if (!String.IsNullOrEmpty(actionProperty)) { return(actionProperty); } string action; VirtualPath clientFilePath = Context.Request.ClientFilePath; // ASURT 15075/11054/59970: always set the action to the current page. // DevDiv Servicing 215795/Dev10 567580: The IIS URL Rewrite module and other rewrite // scenarios need the postback action to be the original URL. Note however, if Server.Transfer/Execute // is used, the action will be set to the transferred/executed page, that is, the value of // CurrentExecutionFilePathObject. This is because of ASURT 59970 and the document attached to // that if (Context.ServerExecuteDepth == 0) { // There hasn't been any Server.Transfer or RewritePath. // ASURT 15979: need to use a relative path, not absolute action = clientFilePath.VirtualPathString; int iPos = action.LastIndexOf('/'); if (iPos >= 0) { // Ensure the segment is always a relative path, so prepend a dot-segment // (RFC section 4.2 Relative Reference) action = "./" + action.Substring(iPos + 1); } } else { VirtualPath currentFilePath = Context.Request.CurrentExecutionFilePathObject; // Server.Transfer or RewritePath case. We need to make the form action relative // to the original ClientFilePath (since that's where the browser thinks we are). currentFilePath = clientFilePath.MakeRelative(currentFilePath); action = currentFilePath.VirtualPathString; } // VSWhidbey 202380: If cookieless is on, we need to add the app path modifier to the form action bool cookieless = CookielessHelperClass.UseCookieless(Context, false, FormsAuthentication.CookieMode); if (cookieless && Context.Request != null && Context.Response != null) { action = Context.Response.ApplyAppPathModifier(action); } // Dev11 406986: <form> elements must have non-empty 'action' attributes to pass W3 validation. // The only time this might happen is that the current file path is "", which meant that the // incoming URL ended in a slash, so we can just point 'action' back to the current directory. if (String.IsNullOrEmpty(action) && RenderingCompatibility >= VersionUtil.Framework45) { action = "./"; } // Dev11 177096: The action may be empty if the RawUrl does not point to a file (for e.g. http://localhost:8080/) but is never null. // Empty action values work fine since the form does not emit the action attribute. Debug.Assert(action != null); string queryString = Page.ClientQueryString; // ASURT 15355: Don't lose the query string if there is one. // In scriptless mobile HTML, we prepend __EVENTTARGET, et. al. to the query string. These have to be // removed from the form action. Use new HttpValueCollection to leverage ToString(bool encoded). if (!String.IsNullOrEmpty(queryString)) { action += "?" + queryString; } return(action); }