ASP.NET MVC Tips

//Getting a path
var path = HttpContext.Server.MapPath("~/App_Data");
var directory = HttpContext.Server.MapPath("~/Photos");

//RedirectToAction between areas
 return RedirectToAction("ActionMethodName", "ControllerName", new { area = "AreaName" });



//Web.Config template =============================
<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>
     <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
  </configSections>
  <appSettings>
     <add key="webpages:Version" value="3.0.0.0" />
     <add key="webpages:Enabled" value="false" />
     <add key="ClientValidationEnabled" value="true" />
     <add key="UnobtrusiveJavaScriptEnabled" value="true" />
  </appSettings>
  <system.web>
     <compilation debug="true" targetFramework="4.5" />
     <httpRuntime targetFramework="4.5" />
     <customErrors defaultRedirect="~/DSR/Error" mode="Off">
       <!--<error statusCode="500" redirect="InternalError.htm"/>-->
     </customErrors>
   </system.web>
   <connectionStrings>
     <add name="MyConnectionString" connectionString="Data Source=182.160.99.115\SQLSERVER2008;Initial Catalog=RobiPosMapping;User ID=sa;Password=sqladmin@123" providerName="System.Data.SqlClient" />
     <add name="RobiPosMappingEntities" connectionString="metadata=res://*/DataAccess.RobiPos.csdl|res://*/DataAccess.RobiPos.ssdl|res://*/DataAccess.RobiPos.msl;provider=System.Data.SqlClient;provider connection string="data source=182.160.99.115\SQLSERVER2008;initial catalog=RobiPosMapping;user id=sa;password=sqladmin@123;MultipleActiveResultSets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
   </connectionStrings>
   <entityFramework>
     <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
 <providers>
 <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
 </providers>
 </entityFramework>
</configuration>
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s