Web Deployment Project location/Authorization replacement

  • Thread starter Thread starter Chuck
  • Start date Start date
C

Chuck

I have a sub directory in an asp.net project with its own web.config.
During "Test" the Role Test is authorized for the sub directory.
During "Release" the test role is not authorized in the sub directory.

I don't believe the web deployment project allows replacing sections in
web.config files nested in sub directories?

I tried deleting the nested web.config and creating a"location" section in
the root web.config. However, the web deployment project errors with error
WDP00002: "missing section location".

I can kind of see this erroring since their could be multiple locations
sections within a web.config with each Location section having a different
Path element.

Is there a good way to change what roles are authorized in a sub directory
with a web deployment project configuration.

thanks,
 
Hi,
During "Test" the Role Test is authorized for the sub directory.
During "Release" the test role is not authorized in the sub directory.

Is my understanding correct that you're using membership and roles in your
Web Application, when you test your project in Visual Studio the
authorization works properly. However, after publishing to IIS it doesn't
work?

If so do you get any exceptions?

I did a test. By adding the following web.config in a sub directory the
authorization works fine (both in debug and product scenario). If role1
want to access the resources it'll be denied.

<?xml version="1.0"?>

<configuration>
<system.web>
<authorization>
<allow roles="role2" />
<deny roles="role1" />
</authorization>
</system.web>
Is there a good way to change what roles are authorized in a sub directory
with a web deployment project configuration.

If you've published your site to IIS, you can open the Web Site in Visual
Studio. Then click "WebSite" (on the menu bar of Visual Studio)->"ASP.NET
Configuration". After that, a administration page will be opened. You can
config settings there. By clicking "Security" tab you can simply change the
Access Rules settings following the instruction on the page.

Please let me know if it can solve this issue and feel free to ask if you
have additional questions.

Regards,
Allen Chen
Microsoft Online Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subscriptions/aa948868.aspx#notifications.

Note: MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 2 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions. Issues of this
nature are best handled working with a dedicated Microsoft Support Engineer
by contacting Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/en-us/subscriptions/aa948874.aspx
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 
I have a sub directory in an asp.net project with its own
web.config.
During "Test" the Role Test is authorized for the sub directory.
During "Release" the test role is not authorized in the sub directory.

I don't believe the web deployment project allows replacing sections
in web.config files nested in sub directories?

Not directly, but you can create a post bulid step that replaces it, if
that is your goal. I have not checked, but some of the CI products out
there (or perhaps nAnt) allows this granularity and might be worthwhile
to look at.

Some of this changes in VS 2010 where there are bits to handle different
configs. I am not sure how it handles subdirectory, however.

Is there a good way to change what roles are authorized in a sub
directory with a web deployment project configuration.

Not sure. The web deployment currently shipping is rather problematic,
so I don't use it. our method of customizing is to have a separate file
for hte changed elements on the web server and exclude that file from
publish. We then x-copy files over. But this is not a "location" thing.

Post build overwrite is still an option, in my book, although it is
possibly a bit kludgy. But it may be the only workable option until .NET
4.0.

Peace and Grace,


--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

Twitter: @gbworld
Blog: http://gregorybeamer.spaces.live.com

My vacation and childhood cancer awareness site:
http://www.crazycancertour.com

*******************************************
| Think outside the box! |
*******************************************
 
In web deployement projects you can have different configurations
like debug, test, and release.
People will use the web.config file section replacment to do things like
changing the connectionstrings section when changing from test to release.

I want to have different roles allowed for a subdirectory when I move from
test to release. I wanted to know if their is a way to do this with a web
deployment project. Either by changing the LOCATION setting in the root
web.config or replacing the sub directory web.config or a section within in
it.
 
Hi,
I want to have different roles allowed for a subdirectory when I move from
test to release. I wanted to know if their is a way to do this with a web
deployment project. Either by changing the LOCATION setting in the root
web.config or replacing the sub directory web.config or a section within in
it.

Thanks for your clarification. If you want to replace a string in a file,
you can use custom task.

Please download MSBuildExtension Pack:
http://msbuildextensionpack.codeplex.com/Release/ProjectReleases.aspx?Releas
eId=18971

Then open .csproj_deploy file in Visual Studio, then add following content,
make sure C:\Program Files
(x86)\MSBuild\ExtensionPack\MSBuild.ExtensionPack.dll and Folder\web.config
is the valid path in your environment. (you can get the dll from above
site, Folder is the sub folder of your web application)

<Project ToolsVersion="3.5" DefaultTargets="Build;MyTarget"
xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<UsingTask TaskName="MSBuild.ExtensionPack.FileSystem.File"
AssemblyFile="C:\Program Files
(x86)\MSBuild\ExtensionPack\MSBuild.ExtensionPack.dll"/>

....

<Target Name="MyTarget" Condition=" '$(Configuration)|$(Platform)' ==
'Release|AnyCPU' ">
<MSBuild.ExtensionPack.FileSystem.File TaskAction="Replace"
RegexPattern="role3" Replacement="role1"
Files="$(MSBuildProjectDirectory)\Release\Folder\web.config"/>
</Target>

<Import
Project="$(MSBuildExtensionsPath)\Microsoft\WebDeployment\v9.0\Microsoft.Web
Deployment.targets" />
</Project>

If you build on Release|AnyCPU condition, you'll see the "role3" in
Folder\web.config will be replaced by "role1". Please have a test and let
me know if it can solve this issue.

Regards,
Allen Chen
Microsoft Online Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).
 
Hi,
I want to have different roles allowed for a subdirectory when I move from
test to release. I wanted to know if their is a way to do this with a web
deployment project. Either by changing the LOCATION setting in the root
web.config or replacing the sub directory web.config or a section within in
it.

Have you solved this issue? If you have additional questions please don't
hesitate to let me know.

Regards,
Allen Chen
Microsoft Online Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).
 
Back
Top