Counter-Build the mvc+silverlight process on virtual space

Source: Internet
Author: User
Tags ftp httpcontext iis zip silverlight

Happened to my new colleague, more than once. I hope you see no anger, no one knows who my colleague is. When I send ftp://192.168.123.4, our company's FTP address to them and tells them that the company information is part of the above. Their first reaction is to enter the browser. There was another expression: enter into the resource manager. They were all first stunned. I mean the address bar of a folder that has already been opened. They just came to the realization.
Later I think, one is a little unfamiliar with the knowledge of FTP, the second is the name of the resource manager is also relatively unfamiliar. It can be seen that some basic operating system knowledge or lack of. So it is said that it is important to teach WEB,FTP deployment in the network class. Do those so-called professional names and terminology really work?
Virtual Space Site Deployment I recommend FTP tool deployment more. Today, use Windows Explorer to access replication directly.

After logging in, depending on the service provider you will have different files. This is usually the three. I have seen 4, 5 kinds of virtual host space is like this. But there should be exceptions.
DB: A backup of the Web, a backup folder for the database
LOG: folder where Web history is stored
Web: That's where you're going to put your website.
Web Publishing
Right-click on a website item, click Publish, as shown below
Here feel the virtual host needed, I only say FTP with file system deployment.
FTP deployment:
Two single views have been made clear, not to mention
The Web folder here is a virtual host that puts the site directory in a Web folder. Fill in the path according to your situation. and fill in the username and password can be released.
But this method is not very stable, but sometimes it fails several times. The reason for the VS output explanation is that it may be a network problem, a security issue, or no reason to know. This is the time to change the file system deployment bar.
File System Deployment:
Here the target location specifies an empty folder, otherwise the file will be published to that folder directory, if it is a file folder, it will be very messy. OK, click Publish

I have one more Web folder on my desktop. Then, just copy the contents to the FTP Web folder above! Your website has been published successfully!
So it's over? No! You don't have to be happy too early, we're deploying mvc!.
The deployment of MVC needs to be known
Thinking back, we're going to build a mvc3 step:
Install good vs2010, new project found no MVC3, understand not installed
Internet MVC3 installation package, Han-bag, installation ...
New project, choose. NET formwork4.0, there are.
New good, you can run it.
Then, as in the previous steps, publish the MVC3 project.
There are only 4 files under the bin. Yes, you can run when you press F5, everything is OK.
But it's not necessarily possible to run it. Why?
Recall the MVC installation step.
If you are not publishing to IIS on this computer. You can guarantee that the machine that publishes the target installs the MVC3 installation package.
What do we do with the machines that don't have MVC3 installed?
Analyze the problem:
What is the difference between installing a MVC3 machine? Open it:
64 bits: C:Program Files (x86) Microsoft asp.net
32 digits:c:program filesmicrosoft asp.net

That's not the point. Now open your project, find references, press F4 or click on the System.Web.Mvc menu, point properties
Look at the attribute illustrated words:
Runtime version:
. NET 4.0 is required. This means that the application of this DLL must be. NET 4.0. Of course, there are a lot of files available with 2.0 support, such as system.web and 2.0 runtime versions. However, the runtime of the MVC3 must be 4.0, because the internal code must use 4.0 of the relevant functionality.
Copy Local: Just do not copy this DLL to the Bin folder, the so-called local, is replicated with the release
path: that is, this DLL file holds the path. Here's the point. The path of déjà vu. Yes, that's MVC3 installation path!
Description: How do you refer to a DLL in the MVC3 installation directory when a net4.0 is installed without installing a MVC3 machine? So we have to copy the local, let vs put the MVC3 DLL, put in the bin, the problem is solved. Therefore, there is no installation of MVC3 machine, as long as the Copy local, you can solve this problem.
Further explanation : Not only MVC3 this DLL installed on the machine will not be, most of the DLLs may not be. Simply put, unless the. NET 4.0 native-supported DLL is installed when the. NET Formwork 4.0 is installed. Many of the DLLs were installed because we installed VS2010. such as System.Web.Helpers is a vs2010 after the installation of the DLL.
So the easiest way to do this is to set it all to replicate locally. The DLL itself is not large. It's usually a few MB. No burden on space. The next release is the time to select Replace matching files with local copies. This avoids duplicating the DLL. This is also a problem to be concerned with deploying MVC3.
Some people would say, I just don't want to copy it all, how do I know that?
When you publish a Web that lacks a DLL, you will get an error when you visit. However, for security reasons, the error is not displayed. So you have to open the web.config in the show.
<system.web>
<customerrors mode= "on"/>
On represents open. Open your website again and you will find that it is different.
No matter what the English says first. The red line is your DLL. (Beware of changes in the page but cannot be seen because IE caches pages)
And then what?

yourself go to have a DLL on your own installation path find that DLL copied to the published Web's Bin directory.
It is said that it is most convenient to replicate locally. Oh!
MVC Path Resolution
mvc3 to deploy on IIS6, it is not enough to solve the problem of. NET 4.0 and DLLs. There is also a path resolution problem.
This problem is in the IIS6 deployment, IIS6 above version will not have.
Add Resolution: Right-click the Web site in IIS select Properties-Home Directory-configuration-map-insert, CONFIGURED as follows: C:windowsmicrosoft.netframework 4.0.30196spnet_ Isapi.dll, confirm that the file exists: uncheck Click OK, and finally the following figure shows:
To change IIS6, what about the virtual host?
first accept the reality. Always can not solve this problem black someone else server it!
Then find a service provider to talk about this change to the customer service or technical staff. Let them to solve.
But things are often not so smooth.
The other side may not have the right to operate the server, or do not provide configuration services, or to lead approval after the end.
Then we have to be self-reliant! Through the roundabout to reach my goal.
need to add two files to the project and modify Global.asax.cs
Add: default.aspx, all contents as follows:
%>
<%--Please don't delete this file. It is used to ensure that asp.net MVC Yes activated by IIS if a user makes a "/" request to the server. --%>
code file: Default.aspx.cs, all contents as follows:
 using  system.web;  Using  SYSTEM.WEB.MVC; 

Using  System.Web.UI;  namespace  demonstrateweb { public partial class _default:  Page   { /span>public void Page_Load (object sender, System.EventArgs  e) { //Change the Curr ENT path so this Routing handler can correctly interpret//the request, then restore the original path so The OutputCache module//can correctly process the response (if caching is enabled).  string  originalpath = Request.path;  HttpContext.Current.RewritePath (Request.applicationpath, false );  IHttpHandler HttpHandler = new Mvchttphandler  (); Httphandler.processrequest ( HttpContext . Current);  HttpContext.Current.RewritePath (Originalpath, false ); } } } 
Adding such a file is because there is no Default.aspx home page in MVC.
We need to have the default home page go to the route of MVC.
Modify Global.asax.cs
 public static void RegisterRoutes (RouteCollection  routes) {routes.

            Ignoreroute ( "{resource}.axd/{*pathinfo}" ); Routes. Maproute ( Default, //Routing name  "{controller}/{action}.aspx/{id}",  URL with parameter  new {controller = "Home", action = "Index", id = urlparameter.optional} //parameter defaults
            Recognized value  ); Routes. Maproute ( "Noaction", "{controller}.aspx", new {controller = "Home", action = "index", id = ""}); //No action match  routes. Maproute ("Noid", "{controller}/{action}.aspx", new {controller = "Home", action = "index", id = ""}); //No ID match  routes. Maproute ("Root", "", new {controller = "Home", action = "index", id = ""}); //root directory match  }  
Here we change the route registration function. In fact, the simple thing is to add aspx behind all the paths. Such as:
Http://localhost:3572/home/index.aspx
So IIS6 can be identified, it must make you very tangled, but there is no better way.
said that if the service provider's technicians can help me to handle the path resolution is the best!
Deployment issues for Silverlight
the problem with Silverlight deployment is that the. xap file name can be supported by the server.
Way to solve:
Add MIME type.
. xaml Application/xaml+xml
. xap Application/x-silverlight-app
As shown in figure:

Many service Chambers host management provides this service.
The following method is searched for, not tried,
But most of the time we don't have permission to manipulate IIS.
Change the. xap file name to. zip (cause you should know that the Xap file is actually zip). However, zip may not be supported by the server because the free space can only display html! So I changed the XAP. The Html,silverlight program can be magically displayed in the HTML page.

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.