Mihai Tibrea
Mihai Tibrea

Reputation: 641

How to deploy mvc application

I have finished an mvc application and i want to publish it on a test website. I managed to publish the files with the Publish command in VS, but when i access the link to my app, nothing.

I used FTP to publish the website, i checked if the files are on the host, they are, but the application does not open. The index.cshtml is not showing. Do i need to do some extra configuration in order to make it work ?

Also, i followed the steps from http://msdn.microsoft.com/en-us/library/dd410407(v=vs.90).aspx.


Is there any change i have to make to the web.release.config and web.debug.config ?

here is my web.config :

<configSections>

<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<connectionStrings>
  <add name="DefaultConnection" connectionString="Data Source=xxxxx Initial Catalog=xxxx; Persist Security Info=True; User ID=xxxxx; Password=xxxxx" providerName="System.Data.SqlClient" />
<add name="CDSEntities" connectionString="metadata=res://*/Models.CDS.csdl|res://*/Models.CDS.ssdl|res://*/Models.CDS.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=xxxx;initial catalog=xxxxx;user id=xxxx;password=xxxxx;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" /></connectionStrings>

and here is my web.release.config :

<system.web>
<compilation xdt:Transform="RemoveAttributes(debug)" />
<!--
  In the example below, the "Replace" transform will replace the entire 
  <customErrors> section of your Web.config file.
  Note that because there is only one customErrors section under the 
  <system.web> node, there is no need to use the "xdt:Locator" attribute.

  <customErrors defaultRedirect="GenericError.htm"
    mode="RemoteOnly" xdt:Transform="Replace">
    <error statusCode="500" redirect="InternalError.htm"/>
  </customErrors>
-->

and my web.debug.config :

<system.web>
<!--
  In the example below, the "Replace" transform will replace the entire 
  <customErrors> section of your Web.config file.
  Note that because there is only one customErrors section under the 
  <system.web> node, there is no need to use the "xdt:Locator" attribute.

  <customErrors defaultRedirect="GenericError.htm"
    mode="RemoteOnly" xdt:Transform="Replace">
    <error statusCode="500" redirect="InternalError.htm"/>
  </customErrors>
-->

Upvotes: 1

Views: 272

Answers (1)

Mihai Tibrea
Mihai Tibrea

Reputation: 641

To answer my own question : What i did was the following :

Publish using VS, added the files using FTP on the server.

Then i added the following to the web.config because i got the following error :

Server Error in '/' Application. There is no build provider registered for the extension '.cshtml'. You can register one in the section in machine.config or web.config. Make sure is has a BuildProviderAppliesToAttribute attribute which includes the value 'Web' or 'All'.

So i added the following :

<compilation debug="true" targetFramework="4.0">

  <assemblies>
    <add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
    <add assembly="System.Web.Helpers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
    <add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
    <add assembly="System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
    <add assembly="System.Web.WebPages, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
  </assemblies>
</compilation>

after this In web.release.config i added my connection string from the web.config. I will give an example to make it clearer :

<connectionStrings>
  <add name="EAF" connectionString="Data Source=NTSQLT\S2K5TST;Initial Catalog=HR;User ID=EAFApp;Password=XXXX" providerName="System.Data.SqlClient" />
</connectionString>

and the web.release.config i added xdt:Transform="SetAttributes" xdt:Locator="Match(name)" for each connection string.

<connectionStrings>
  <add name="EAF" connectionString="Data Source=NTSQLP\S2K5TST;Initial Catalog=HR;User ID=EAFApp;Password=YYYY" xdt:Transform="SetAttributes" xdt:Locator="Match(name)" />
 </connectionStrings>

Upvotes: 1

Related Questions