Using Microsoft ASP. Net MVC Framework + collecting feedback on bugs found by garden friends [Supplement]

Source: Internet
Author: User
Tags actionlink

OriginalArticleSee: http://www.cnblogs.com/szw/archive/2007/12/18/1004344.html

Here, I will summarize some other bugs and related opinions and suggestions raised by many garden friends, as well as my test results on some of these solutions.

--Reference--------------------------------------------------
Han xilong: What the landlord said is: I don't know whether the problem is that the younger brother is easy to learn or ms mvc. I am. the CS page cannot be referenced. the runat = & quot; server & quot; control on the ASPX page .. This really makes me depressed and angry !!
Also, Scott wrote an article about MVC about unit testing of the detail method, but I didn't have the object testviewengine locally...
--------------------------------------------------------

Corresponding bug: The original codefile was replaced by codebehide (whether intentionally or not, but it seems that there is no official explanation of the benefits of deliberately doing so ). We all know that at the beginning of vs2005, the biggest difference between webapplication and website files is that there will be one more. aspx file for webapplication.. Designer. CS/. VB file (vs2003 contains another file. If you remember correctly, it seems to be. resx). If this file is missing in MVC, it cannot be stored in. aspx. CS call. aspx control, while in. direct calling in aspx is acceptable.

Solution and description: Http://www.cnblogs.com/QLeelulu/archive/2007/12/12/992660.html

  • About the format of "[controller]. MVC/[action]/[ID]" under IIS6 (. MVC) // Note: Change url = to url = "[controller]. MVC/[action]/[ID]" to enable
    // Automatic support on IIS6

    Problem:
    --Reference--------------------------------------------------
    5. One of the biggest headaches should be solved at the MVC technical level: Open the global. asax of MVC, and we can look at the following sentence:

    // Note: Change url = to url = "[controller]. MVC/[action]/[ID]" to enable
    // Automatic support on IIS6

    --------------------------------------------------------
    For more information, see the fifth point of my original article.

    Solution and description :
    Solution 1:
    -- Reference --------------------------------------------------
    Pigo: For the last problem, my solution is to put "[controller]. MVC/[action]/[ID] "expression written as" [controller]/[ID]/[action]. aspx"
    I have tested it. It is okay to write it like this. Of course, it is written as "[controller]/[action]/[ID]. aspx "is also acceptable, as long as it is finally handed over to ASP. net.
    --------------------------------------------------------
    Test results: This method is indeed feasible, but this method exposes a bug that is not a bug (it can be said that it is a bug of this solution or use notes ):
    When I use this method, there is no problem with the link in the past. The format is "[controller]/[action]/[ID]. aspx ": <% # Html. actionlink ( " Edit " , New {Action = " Plateedit " , ID = Eval ( " Plateid " )}) %>

    However, if I use HTML. the actionlink <t> format is: "[controller]/[action]/. aspx/[ID] ", Error 404 (that is, the webpage cannot be found ). Even if you change it to "[controller]/[action]/[ID]. the aspx format is directly opened in the browser, and will automatically jump to "[controller]/[action]/. aspx/[ID] "format, and an error is returned.
    My guess is routetable. when routes is executed or restructured, it always adds the last parameter (as shown in [ID] above) to the end, and at this time it constitutes "[controller]/[action]/. the format of Aspx. Even if the [controller] process has no internal error, the address format of the renderview has changed (according to the final format merged ), this is the case (but not just the case ). Therefore, MVC is not followed by [controller] Because [ID] is followed by [action.

    It seems that when this method is used, HTML. Action () and HTML. Action <t> () cannot be completely used at present.

    Solution 2:
    --Reference--------------------------------------------------
    Yanghan: @ SZW
    Well, I also saw someone saying that I had to add the MVC extension to the ISAPI processing of Asp.net on iis6.
    Modify the HTML extension and submit it to the ISAPI processing function of Asp.net.
    [Controller]/[action]/[id).html
    --------------------------------------------------------
    Test results:Another option (also the most ideal option) is to solve the problem. In this case, we have to modify the example. html, which is not successful yet.

  • About the HTML of mvctoolkit. actionlink () I just found a bit unreasonable (other controls may have similar situations): When I input the htmlattributes field, I also enter the following parameters:New {onclick = "alert ('Hello tnt2! ');"}

    If I use the HTML. actionlink <t> () method, no error occurs. When I use the HTML. actionlink () method, the following error occurs:Cs1502: The best overloaded method match for 'System. Web. MVC. htmlhelper. actionlink (string, String, string) 'has some invalid arguments

    So how can I use onclick in HTML. actionlink? I found a very interesting thing. At first I found that I only needed to change onclick to onclick! However, if I was typing, I tried again for the sake of Prudence. I was still wrong!

    It seems that this html. Action <t> () and HTML. Action () are still a little irrelevant ......

    PS: solutions to some similar problems. For details, refer to: the radical solution for some bugs found in MVC toolkit part (1)

  • In addition, the parameter format arrangement and corresponding comments of HTML. Action (the root cause is the previous problem) are messy when they are used. I don't know if I have used them. For example, the second parameter clearly indicates that it is a value (assuming it is a value parameter). When you finish the input, the second parameter is no longer a value, but something else, you must go back and modify it. Unless you know his format well and think about what you want to lose and ignore his comments, it seems a bit of a waste of feelings ...... In addition, most people would like to remember those things, such as the order of so many parameters in the case of HTML. Select ......
  • This is a summary for the time being!

    Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.