我正在为我的雇主基于个人资料的网络应用程序开发一个简单的评级系统。这是我的问题:
- 实际页面是
domain.com/review.aspx?user=username
,但是我使用 IIS 中的 url-rewrite 模块来使用domain.com/username/review
- 该页面包含一个显示该用户名的评论的转发器控件,以及一个供人们创建新评论的表单
- 提交表单后,asp.net 会在回发时将(隐藏的)查询字符串重新附加到 url。
- 回发网址现在是
domian.com/username/review?user=username&review
,如果刷新会导致页面中断。
有什么方法可以防止 asp.net 重新附加实际上已经存在但用 IIS 重写的查询字符串
实时链接<-提交评论,然后通过单击地址栏刷新页面(编辑)!美丽的黄色错误信息。
编辑
C#代码:
protected void submitReview(object sender, EventArgs e)
{
try
{
int starRating = txtStarRating.Text == "" ? 0 : Int32.Parse(txtStarRating.Text);
testimonials.addNew(Int32.Parse(txtHiddenUid.Text), reviewContent.Text, reviewerName.Text, true, starRating);
reviewForm.Visible = false; pnlReviewSubmissionSuccess.Visible = true;
}
catch { starErrorMessage.Text = "There was an error submitting your review. Please refresh this page and try again."; }
}
ASP 代码:
<div ID="pnlSubmitReview" runat="server">
<div id="reviewForm" runat="server">
<div id="leaveReviewBoxes">
<span style="margin-bottom:10px; float:left; font-weight:bold;">Leave a Review</span>
<div style="clear:both;"></div>
<asp:Label ID="nameLabel" runat="server">Name:</asp:Label>
<asp:Textbox runat="server" ID="reviewerName"></asp:Textbox>
<div style="clear:both;"></div>
<asp:Label ID="reviewLabel" runat="server">Review:</asp:Label>
<asp:Textbox runat="server" ID="reviewContent" Width="200px" TextMode="MultiLine"></asp:Textbox>
</div>
<div>
<ol id="starlist">
<li><a id="star1" name="star1" href="javascript:void(0)" class="star"></a></li>
<li><a id="star2" name="star2" href="javascript:void(0)" class="star"></a></li>
<li><a id="star3" name="star3" href="javascript:void(0)" class="star"></a></li>
<li><a id="star4" name="star4" href="javascript:void(0)" class="star"></a></li>
<li><a id="star5" name="star5" href="javascript:void(0)" class="star"></a></li>
</ol>
<asp:TextBox ID="txtStarRating" runat="server" Text=""></asp:TextBox>
<asp:Label runat="server" ID="starErrorMessage"></asp:Label>
<asp:TextBox ID="txtHiddenUid" runat="server" Visible="false"></asp:TextBox>
</div>
<asp:Button runat="server" ID="submitReviewButton" Text="Submit Review" OnClick="submitReview" />
</div>
<div ID="pnlReviewSubmissionSuccess" runat="server" Visible="false">
Thank you! Your review has been submitted.
</div>
</div>