Using Visual Studio 2015 mvc 5 application. I have created an SSRS report with Visual Studio 2012 that does not take any parameters (yet). I used nuget to add ReportViewerForMvc. I went through an online tutorial to create ReportTemplate.aspx etc. I'm using Forms Authentication so I changed my data sources to use a static SQL Login in SSRS. When I run the report manually I get 151 pages. When I run it through the application the toolbar at the top reads 1 of 151 pages. However, I can't see the body of the report and all the buttons on the toolbar are disabled. I've been fiddling with the control properties in the ReportTemplate.aspx.cs (code behind) and the ReportTemplate.aspx but nothing seems to change it.
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
try
{
String reportFolder = System.Configuration.ConfigurationManager.AppSettings["SSRSReportFolder"].ToString();
String reportUri = System.Configuration.ConfigurationManager.AppSettings["SSRSReportUri"].ToString();
rvSiteMapping.Height = Unit.Pixel(2000);
rvSiteMapping.ProcessingMode = Microsoft.Reporting.WebForms.ProcessingMode.Remote;
rvSiteMapping.ServerReport.ReportServerUrl = new Uri(reportUri); // Add the Reporting Server URL
rvSiteMapping.ServerReport.ReportPath = String.Format("/{0}/{1}", reportFolder, Request["ReportName"].ToString());
rvSiteMapping.ServerReport.Timeout = 320000;
rvSiteMapping.ServerReport.Refresh();
rvSiteMapping.ShowReportBody = true;
rvSiteMapping.ShowToolBar = true;
rvSiteMapping.SizeToReportContent = true;
rvSiteMapping.Enabled = true;
rvSiteMapping.Visible = true;
}
catch (Exception ex)
{
Console.Write(ex.Message);
}
}
}
Package Entries:
<package id="MicosoftReportViewerWebForms_v11" version="1.0.1" targetFramework="net451" />
<package id="ReportViewerForMvc" version="1.0.0" targetFramework="net451" />
Web.Config:
<httpHandlers>
<add path="Reserved.ReportViewerWebControl.axd" verb="*" type="Microsoft.Reporting.WebForms.HttpHandler, Microsoft.ReportViewer.WebForms, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" validate="false" />
</httpHandlers>
...
<handlers>
<remove name="ExtensionlessUrlHandler-Integrated-4.0" />
<remove name="OPTIONSVerbHandler" />
<remove name="TRACEVerbHandler" />
<add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
<add name="ReportViewerWebControlHandler" preCondition="integratedMode" verb="*" path="Reserved.ReportViewerWebControl.axd" type="Microsoft.Reporting.WebForms.HttpHandler, Microsoft.ReportViewer.WebForms, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" />
</handlers>
Thanks
Lee
Related
Briefly:
Bundles which contain items from a VirtualPath (Served by custom VirtualPathProvider) don't work. Hash isn't generated in the v= and resolving them shows the .Items property as empty.
Detailed:
Suppose we have a bundle registration:
bundles.Clear();
bundles.ResetAll();
BundleTable.EnableOptimizations = true;
bundles.Add(new StyleBundle("~/bundles/css")
.Include("~/Content/site.css"));
bundles.Add(new StyleBundle("~/bundles/admin/somestyle")
.Include("~/Areas/Admin/Content/css/aaa2.css"));
Some notes here:
~/bundles/admin/somestyle physically doesn't exist.
~/Areas/Admin/Content/css/aaa2.css is a virtual path which is handled by a custom VirtualPathProvider
~/bundles/css is served by default MapPathBasedVirtualPathProvider
Relevant part of current Web.config file:
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<modules runAllManagedModulesForAllRequests="false"/>
<handlers>
<remove name="OPTIONSVerbHandler" />
<remove name="TRACEVerbHandler" />
<remove name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" />
<remove name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" />
<remove name="ExtensionlessUrlHandler-Integrated-4.0" />
<add name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness32" responseBufferLimit="0" />
<add name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness64" responseBufferLimit="0" />
<add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
<add name="AspNetStaticFileHandler-TIFF" path="*.tiff" verb="*" type="System.Web.StaticFileHandler" />
<add name="AspNetStaticFileHandler-GIF" path="*.gif" verb="*" type="System.Web.StaticFileHandler" />
<add name="AspNetStaticFileHandler-PNG" path="*.png" verb="*" type="System.Web.StaticFileHandler" />
<add name="AspNetStaticFileHandler-JPG" path="*.jpg" verb="*" type="System.Web.StaticFileHandler" />
<add name="AspNetStaticFileHandler-CSS" path="*.css" verb="*" type="System.Web.StaticFileHandler" />
<add name="AspNetStaticFileHandler-JS" path="*.js" verb="*" type="System.Web.StaticFileHandler" />
<add name="AspNetStaticFileHandler-WOFF" path="*.woff" verb="*" type="System.Web.StaticFileHandler" />
<add name="AspNetStaticFileHandler-TTF" path="*.ttf" verb="*" type="System.Web.StaticFileHandler" />
<add name="AspNetStaticFileHandler-MAP" path="*.map" verb="*" type="System.Web.StaticFileHandler" />
</handlers>
</system.webServer>
Routing entries:
routes.IgnoreRoute("favicon.ico");
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
AreaRegistration.RegisterAllAreas();
RouteConfig.RegisterRoutes(RouteTable.Routes);
Test Drive:
1. Trying to access the .css files directly:
http://localhost:1010/Areas/Admin/Content/css/aaa2.css - File found => Custom VirtualPathProvider did his job.
2. Trying to resolve bundles from HomeController:
public ActionResult Test()
{
var bundleVirtual = BundleTable.Bundles.GetBundleFor("~/bundles/admin/somestyle");
var bundleVirtualUrl = BundleTable.Bundles.ResolveBundleUrl("~/bundles/admin/somestyle");
var bundleOrdinary = BundleTable.Bundles.GetBundleFor("~/bundles/css");
var bundleOrdinaryUrl = BundleTable.Bundles.ResolveBundleUrl("~/bundles/css");
return View();
}
bundleVirtual is found but .Items property is empty.
bundleVirtualUrl is /bundles/admin/somestyle?v= notice that v= has no hash value.
bundleOrdinary is found, .Items has one entry ~/Content/site.css.
bundleOrdinaryUrl is "/bundles/css?v=6bMbVqKBetPV3UISUSkpqR5wiBsbzK_c6J21LUZAzaU1"
Question:
Why resolving "~/bundles/admin/somestyle" shows that there are not Items added, even if the item is registered and the VirtualPathProvider handles it correctly?
Related links:
ASP.NET Bundling/Minification and Embedded Resources
http://www.codeproject.com/Articles/728146/ASP-NET-MVC-bundles-internals
You need to register your VirtualPathProvider before bundle registration, in order to be able to find your files. Any files not found will not be included in bundle.Items
var vpp = new MyVirtualPathProvider();
BundleTable.VirtualPathProvider = vpp;
BundleConfig.RegisterBundles(BundleTable.Bundles);
Unless of course you already have it registered as HostingEnvironment.VirtualPathProvider.
i'm using web api with asp.net web forms 4.5 and i have problem in delete method .
that not work but other methods work good.
please help .
this my delete method:
[HttpDelete]
public void DeleteConversation(long id)
{
if (_repository.UserConvers(long.Parse(User.Identity.GetUserId())).All(a => a.Id != id))
return;
var item = _repository.Get(id);
if (item == null)
{
throw new HttpResponseException(HttpStatusCode.NotFound);
}
_repository.Remove(id);
}
and this is my web config :
<modules runAllManagedModulesForAllRequests="true">
<remove name="FormsAuthenticationModule" />
<remove name="WebDAVModule"/>
</modules>
<handlers>
<remove name="ExtensionlessUrlHandler-Integrated-4.0" />
<remove name="OPTIONSVerbHandler" />
<remove name="TRACEVerbHandler" />
<add name="CKUpload" path="/Handlers/CKUpload.ashx" verb="*" type="UI.Handlers.CKUpload,UI" />
<add path="Captcha.ashx" verb="*" name="Captcha" type="UI.Handlers.Captcha,UI" />
<add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
</handlers>
Make sure that inside your delete method in _repository class that you are calling SaveChanges(). Nothing wrong with your Method and you should be able to access it by issuing HTTP Delete to uri "/api/{controllerName}/45541"
work with visual studio 2012. I need to load my report viewer inside a div in my web page. But it would be blank. It works fine a separate web page alone, but when I want to load it inside a section inside my content page, it is blank. The part of my code which works with report viewer:
// add a div dynamically
HtmlGenericControl div = new HtmlGenericControl("div");
div.Attributes.Add("id", "chart05");
div.Attributes.Add("runat", "server");
div.Attributes["class"] = "chartItem";
sanaChartsContainer.Controls.Add(div);
Microsoft.Reporting.WebForms.ReportViewer viewer = new Microsoft.Reporting.WebForms.ReportViewer();
viewer.Attributes.Add("id", "ReportViewer");
viewer.Attributes.Add("runat", "server");
viewer.Attributes.Add("Font-Names", "Verdana");
viewer.Attributes.Add("Font-Size", "8pt");
viewer.Attributes.Add("Height", "50px");
viewer.Attributes.Add("ProcessingMode", "Remote");
viewer.Attributes.Add("WaitMessageFont-Name", "Verdana");
viewer.Attributes.Add("WaitMessageFont-Size", "14pt");
viewer.Attributes.Add("Width", "50px");
viewer.Attributes.Add("AsyncRendering", "false");
viewer.ServerReport.Refresh();
viewer.ShowParameterPrompts = false;
Uri baseUri = new Uri("http://mdb165.cbi.net/reportserver");
viewer.ServerReport.ReportServerUrl = baseUri;
viewer.ServerReport.ReportPath = "/SanaII/report005";
System.Web.UI.ScriptManager scriptManager = new ScriptManager();
Page page = new Page();
System.Web.UI.HtmlControls.HtmlForm form = new HtmlForm();
//div.Controls.Add(scriptManager);
div.Controls.Add(viewer);
My web config is:
<configuration>
<system.web>
<compilation debug="true">
<buildProviders>
<add extension=".rdlc" type="Microsoft.Reporting.RdlBuildProvider, Microsoft.ReportViewer.WebForms, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91"/>
</buildProviders>
</compilation>
<httpHandlers>
<add path="Reserved.ReportViewerWebControl.axd" verb="*" type="Microsoft.Reporting.WebForms.HttpHandler, Microsoft.ReportViewer.WebForms, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" validate="false"/>
</httpHandlers>
</system.web>
<system.webServer>
<validation validateIntegratedModeConfiguration="false"/>
<handlers>
<add name="ReportViewerWebControlHandler" preCondition="integratedMode" verb="*" path="Reserved.ReportViewerWebControl.axd" type="Microsoft.Reporting.WebForms.HttpHandler, Microsoft.ReportViewer.WebForms, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91"/>
</handlers>
</system.webServer>
</configuration>
I also added script manager to my page,
but report viewer is blank.
I also tried to load it directly in my content page as below shows:
but this is also doesn't work and is blank.
Please give me help.
Have you tried adding if(!IsPostBack) in your Page_Load?
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
SetDate();
BindCustomerCategory();
BindUtility();
}
}
OR if this will not work. Double check the aspx of your report page you might forgot something there..
Here DataList.aspx & Details.aspx is inside directory v1, so i tried routing in two ways but nothing is working on server.
Global.asax
protected void Application_Start(object sender, EventArgs e)
{
RouteTable.Routes.MapPageRoute("Route1",
"Category/{Brand}.html","~/DataList.aspx");
RouteTable.Routes.MapPageRoute("Route2",
"Category/{Brand}/{Title}.html","~/v1/Details.aspx");
}
I am using this routing in hyperlink inside listview. Url is generated correctly, but when i click on link it shows
"404 - File or directory not found."
I have also added this in web.config
<system.webServer>
<modules runAllManagedModulesForAllRequests="true">
<remove name="UrlRoutingModule" />
<add name="UrlRoutingModule" type="System.Web.Routing.UrlRoutingModule, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e42" />
</modules>
<handlers>
<add name="UrlRoutingHandler" preCondition="integratedMode" verb="*" path="UrlRouting.axd" type="System.Web.HttpForbiddenHandler, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e42" />
</handlers>
</system.webServer>
I am building a service stack for the first time: hello world.
I have followed the step by step guide in here:
but it is giving me an error: Handler for Request not found: what could be the missing part? thanks.
here is my global.asax.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.SessionState;
using ServiceStack.ServiceHost;
using ServiceStack.WebHost.Endpoints;
namespace ServiceStack.SearchService
{
public class Global : System.Web.HttpApplication
{
public class Hello { public string Name { get; set; } }
public class HelloResponse { public string Result { get; set; } }
public class HelloService : IService<Hello>
{
public object Execute(Hello request)
{
return new HelloResponse { Result = "Hello, " + request.Name };
}
}
/// Web Service Singleton AppHost
public class HelloAppHost : AppHostBase
{
//Tell Service Stack the name of your application and where to find your web services
public HelloAppHost()
: base("Hello Web Services", typeof(HelloService).Assembly) { }
public override void Configure(Funq.Container container) { }
}
protected void Application_Start(object sender, EventArgs e)
{
//Initialize your application
var appHost = new HelloAppHost();
appHost.Init();
}
void Application_End(object sender, EventArgs e)
{
// Code that runs on application shutdown
}
void Application_Error(object sender, EventArgs e)
{
// Code that runs when an unhandled error occurs
}
void Session_Start(object sender, EventArgs e)
{
// Code that runs when a new session is started
}
void Session_End(object sender, EventArgs e)
{
// Code that runs when a session ends.
// Note: The Session_End event is raised only when the sessionstate mode
// is set to InProc in the Web.config file. If session mode is set to StateServer
// or SQLServer, the event is not raised.
}
}
}
here is my web.config:
<?xml version="1.0" encoding="utf-8"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
<connectionStrings>
<add name="ApplicationServices" connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnetdb.mdf;User Instance=true" providerName="System.Data.SqlClient" />
</connectionStrings>
<system.web>
<compilation debug="true" targetFramework="4.0" />
<authentication mode="Forms">
<forms loginUrl="~/Account/Login.aspx" timeout="2880" />
</authentication>
<membership>
<providers>
<clear />
<add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="ApplicationServices" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" applicationName="/" />
</providers>
</membership>
<profile>
<providers>
<clear />
<add name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="ApplicationServices" applicationName="/" />
</providers>
</profile>
<roleManager enabled="false">
<providers>
<clear />
<add name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider" connectionStringName="ApplicationServices" applicationName="/" />
<add name="AspNetWindowsTokenRoleProvider" type="System.Web.Security.WindowsTokenRoleProvider" applicationName="/" />
</providers>
</roleManager>
<httpHandlers>
<add path="*" type="ServiceStack.WebHost.Endpoints.ServiceStackHttpHandlerFactory, ServiceStack" verb="*" />
<add path="api*" type="ServiceStack.WebHost.Endpoints.ServiceStackHttpHandlerFactory, ServiceStack" verb="*" />
</httpHandlers>
</system.web>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true" />
<validation validateIntegratedModeConfiguration="false" />
<handlers>
<add path="*" name="ServiceStack.Factory" type="ServiceStack.WebHost.Endpoints.ServiceStackHttpHandlerFactory, ServiceStack" verb="*" preCondition="integratedMode" resourceType="Unspecified" allowPathInfo="true" />
</handlers>
</system.webServer>
<location path="servicestack">
<system.web>
<httpHandlers>
<add path="*" type="ServiceStack.WebHost.Endpoints.ServiceStackHttpHandlerFactory, ServiceStack" verb="*" />
<add path="servicestack*" type="ServiceStack.WebHost.Endpoints.ServiceStackHttpHandlerFactory, ServiceStack" verb="*"/>
</httpHandlers>
</system.web>
<!-- Required for IIS 7.0 -->
<system.webServer>
<modules runAllManagedModulesForAllRequests="true" />
<validation validateIntegratedModeConfiguration="false" />
<handlers>
<add path="*" name="ServiceStack.Factory" type="ServiceStack.WebHost.Endpoints.ServiceStackHttpHandlerFactory, ServiceStack" verb="*" preCondition="integratedMode" resourceType="Unspecified" allowPathInfo="true" />
</handlers>
</system.webServer>
</location>
</configuration>
I browse it by typing in the browser.
http://localhost:50097/ServiceStack.SearchService/servicestack/metadata
There is a small step missing from that list that you need if your going to map the services to a custom path. You can find it here:
To quote the missing step:
You also need to configure the root path in your AppHost.
public override void Configure(Container container)
{
SetConfig(new EndpointHostConfig { ServiceStackHandlerFactoryPath = "api" });
}
Where "api" is the name of the custom path you are using.
It looks like you're trying to host ServiceStack both at the / root path and at a mixture of /servicestack and /api custom paths. You need to pick one of them, not a combination of all 3. Here is the config if you want to host at the / root path:
<system.web>
<httpHandlers>
<add path="*" type="ServiceStack.WebHost.Endpoints.ServiceStackHttpHandlerFactory, ServiceStack" verb="*"/>
</httpHandlers>
</system.web>
<!-- Required for IIS 7.0 -->
<system.webServer>
<handlers>
<add path="*" name="ServiceStack.Factory" type="ServiceStack.WebHost.Endpoints.ServiceStackHttpHandlerFactory, ServiceStack" verb="*" preCondition="integratedMode" resourceType="Unspecified" allowPathInfo="true" />
</handlers>
</system.webServer>
The above should replace every other ServiceStack config mapping. Once you've done this you should be able to view the metadata page at:
http://localhost:50097/metadata
Note: If you're running ASP.NET on a port it is unlikely that you also have the Virtual Directory path /ServiceStack.SearchService/.
I had this exact issue I had and could not find a straight answer to - getting a 403.14 error on the simplest ServiceStack demo.
..:: Simple Answer ::..
Your answer is simple. You have confused your handlers by providing 3 instead of one as mentioned by Mythz. Also, You don't have a specified route for your request.
[Route("/hello")]
public class Hello { public string Name { get; set; } }
This will resolve both your 403.13 error (semantic issue) and you can go to your http://{localdomain}:{port}/hello and actually see the metadata (substitute the {port} with the actual port number IIS Express assigned to you). Without this adjustment, you'll need to go to http://{localdomain}:{port}/metadata.
..:: Detailed Answer ::..
Routing, as it relates to IIS in ServiceStack is done by semantics/convention. Since these routes are dynamic, when IIS is not provided proper routing at run time, it assumes that there is a folder issue (physical path) and throws the 403.14 error. At the same time, if you provide more than one path where there should be only one, bad things happen at run time when everything is wired up.
Just to be sure you have all the essentials, here are all the adjustments you need to make to the original code provided.
a. Adjust the web config file to handle just one path as explored in Mythz response
<system.web>
<httpHandlers>
<add path="*" type="ServiceStack.WebHost.Endpoints.ServiceStackHttpHandlerFactory, ServiceStack" verb="*"/>
</httpHandlers>
</system.web>
<!-- Required for IIS 7.0 -->
<system.webServer>
<handlers>
<add path="*" name="ServiceStack.Factory" type="ServiceStack.WebHost.Endpoints.ServiceStackHttpHandlerFactory, ServiceStack" verb="*" preCondition="integratedMode" resourceType="Unspecified" allowPathInfo="true" />
</handlers>
</system.webServer>
b. Make the route adjustment described earlier in this post.