Click here to Skip to main content
15,880,956 members
Articles / Web Development / ASP.NET

Preventive Method for URL Request Forgery- An Example with ASP.NET MVC

Rate me:
Please Sign up or sign in to vote.
4.75/5 (13 votes)
29 Nov 2010CPOL7 min read 75.7K   1.7K   33  
It is novel method to prevent the manipulation of parameter pass through the URL string
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
    <ProductVersion>
    </ProductVersion>
    <SchemaVersion>2.0</SchemaVersion>
    <ProjectGuid>{549C5331-BE20-4AF3-834E-85C0C84E04F4}</ProjectGuid>
    <ProjectTypeGuids>{F85E285D-A4E0-4152-9332-AB1D724D3325};{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
    <OutputType>Library</OutputType>
    <AppDesignerFolder>Properties</AppDesignerFolder>
    <RootNamespace>SecureUrl</RootNamespace>
    <AssemblyName>SecureUrl</AssemblyName>
    <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
    <MvcBuildViews>false</MvcBuildViews>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
    <DebugSymbols>true</DebugSymbols>
    <DebugType>full</DebugType>
    <Optimize>false</Optimize>
    <OutputPath>bin\</OutputPath>
    <DefineConstants>DEBUG;TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
    <DebugType>pdbonly</DebugType>
    <Optimize>true</Optimize>
    <OutputPath>bin\</OutputPath>
    <DefineConstants>TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
  </PropertyGroup>
  <ItemGroup>
    <Reference Include="Microsoft.CSharp" />
    <Reference Include="System" />
    <Reference Include="System.Data" />
    <Reference Include="System.Data.Linq" />
    <Reference Include="System.Drawing" />
    <Reference Include="System.Web.DynamicData" />
    <Reference Include="System.Web.Entity" />
    <Reference Include="System.Web.ApplicationServices" />
    <Reference Include="System.ComponentModel.DataAnnotations">
      <RequiredTargetFramework>3.5</RequiredTargetFramework>
    </Reference>
    <Reference Include="System.Core">
      <RequiredTargetFramework>3.5</RequiredTargetFramework>
    </Reference>
    <Reference Include="System.Data.DataSetExtensions">
      <RequiredTargetFramework>3.5</RequiredTargetFramework>
    </Reference>
    <Reference Include="System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
    <Reference Include="System.Xml.Linq">
      <RequiredTargetFramework>3.5</RequiredTargetFramework>
    </Reference>
    <Reference Include="System.Web" />
    <Reference Include="System.Web.Extensions">
      <RequiredTargetFramework>3.5</RequiredTargetFramework>
    </Reference>
    <Reference Include="System.Web.Abstractions" />
    <Reference Include="System.Web.Routing" />
    <Reference Include="System.Xml" />
    <Reference Include="System.Configuration" />
    <Reference Include="System.Web.Services" />
    <Reference Include="System.EnterpriseServices" />
  </ItemGroup>
  <ItemGroup>
    <Compile Include="Controllers\AccountController.cs" />
    <Compile Include="Controllers\ExamsController.cs" />
    <Compile Include="Controllers\HomeController.cs" />
    <Compile Include="Controllers\QuestionsController.cs" />
    <Compile Include="Controllers\SubjectsController.cs" />
    <Compile Include="Global.asax.cs">
      <DependentUpon>Global.asax</DependentUpon>
    </Compile>
    <Compile Include="Models\AccountModels.cs" />
    <Compile Include="Models\ExamRepository.cs" />
    <Compile Include="Models\QuestionRepository.cs" />
    <Compile Include="Models\SecurityHelper.cs" />
    <Compile Include="Models\SubjectRepository.cs" />
    <Compile Include="Properties\AssemblyInfo.cs" />
    <Compile Include="SecureUrl.designer.cs">
      <AutoGen>True</AutoGen>
      <DesignTime>True</DesignTime>
      <DependentUpon>SecureUrl.dbml</DependentUpon>
    </Compile>
  </ItemGroup>
  <ItemGroup>
    <Content Include="App_Data\ASPNETDB.MDF" />
    <Content Include="App_Data\aspnetdb_log.LDF">
      <DependentUpon>ASPNETDB.MDF</DependentUpon>
    </Content>
    <Content Include="App_Data\Students.mdf" />
    <Content Include="App_Data\Students_log.ldf">
      <DependentUpon>Students.mdf</DependentUpon>
    </Content>
    <Content Include="Global.asax" />
    <Content Include="Views\Questions\UnsecuredQuestionsView.aspx" />
    <Content Include="Views\Shared\ErrorView.aspx" />
    <Content Include="Views\Exams\Index.aspx" />
    <Content Include="Views\Questions\Index.aspx" />
    <Content Include="Views\Questions\QuestionsView.aspx" />
    <Content Include="Views\Subjects\Index.aspx" />
    <Content Include="Web.config" />
    <Content Include="Web.Debug.config">
      <DependentUpon>Web.config</DependentUpon>
    </Content>
    <Content Include="Web.Release.config">
      <DependentUpon>Web.config</DependentUpon>
    </Content>
    <Content Include="Content\Site.css" />
    <Content Include="Scripts\jquery-1.4.1.js" />
    <Content Include="Scripts\jquery-1.4.1.min.js" />
    <Content Include="Scripts\jquery-1.4.1-vsdoc.js" />
    <Content Include="Scripts\jquery.validate.js" />
    <Content Include="Scripts\jquery.validate.min.js" />
    <Content Include="Scripts\jquery.validate-vsdoc.js" />
    <Content Include="Scripts\MicrosoftAjax.js" />
    <Content Include="Scripts\MicrosoftAjax.debug.js" />
    <Content Include="Scripts\MicrosoftMvcAjax.js" />
    <Content Include="Scripts\MicrosoftMvcAjax.debug.js" />
    <Content Include="Scripts\MicrosoftMvcValidation.js" />
    <Content Include="Scripts\MicrosoftMvcValidation.debug.js" />
    <Content Include="Views\Account\ChangePassword.aspx" />
    <Content Include="Views\Account\ChangePasswordSuccess.aspx" />
    <Content Include="Views\Account\LogOn.aspx" />
    <Content Include="Views\Account\Register.aspx" />
    <Content Include="Views\Home\About.aspx" />
    <Content Include="Views\Home\Index.aspx" />
    <Content Include="Views\Shared\Error.aspx" />
    <Content Include="Views\Shared\LogOnUserControl.ascx" />
    <Content Include="Views\Shared\Site.Master" />
    <Content Include="Views\Web.config" />
  </ItemGroup>
  <ItemGroup>
    <None Include="SecureUrl.dbml">
      <Generator>MSLinqToSQLGenerator</Generator>
      <LastGenOutput>SecureUrl.designer.cs</LastGenOutput>
      <SubType>Designer</SubType>
    </None>
    <None Include="SecureUrl.dbml.layout">
      <DependentUpon>SecureUrl.dbml</DependentUpon>
    </None>
  </ItemGroup>
  <ItemGroup>
    <Service Include="{3259AA49-8AA1-44D3-9025-A0B520596A8C}" />
  </ItemGroup>
  <ItemGroup />
  <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
  <Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" />
  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
       Other similar extension points exist, see Microsoft.Common.targets.
  <Target Name="BeforeBuild">
  </Target> -->
  <Target Name="AfterBuild" Condition="'$(MvcBuildViews)'=='true'">
    <AspNetCompiler VirtualPath="temp" PhysicalPath="$(ProjectDir)" />
  </Target>
  <ProjectExtensions>
    <VisualStudio>
      <FlavorProperties GUID="{349c5851-65df-11da-9384-00065b846f21}">
        <WebProjectProperties>
          <UseIIS>False</UseIIS>
          <AutoAssignPort>True</AutoAssignPort>
          <DevelopmentServerPort>49510</DevelopmentServerPort>
          <DevelopmentServerVPath>/</DevelopmentServerVPath>
          <IISUrl>
          </IISUrl>
          <NTLMAuthentication>False</NTLMAuthentication>
          <UseCustomServer>False</UseCustomServer>
          <CustomServerUrl>
          </CustomServerUrl>
          <SaveServerSettingsInUserFile>False</SaveServerSettingsInUserFile>
        </WebProjectProperties>
      </FlavorProperties>
    </VisualStudio>
  </ProjectExtensions>
</Project>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer
India India
I am developer in .Net and GIS. albin_gis@yahoo.com

Comments and Discussions